Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-09-2012, 04:15 PM   PM User | #1
DextrousDave
New to the CF scene

 
Join Date: Mar 2012
Location: South-Africa
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
DextrousDave is an unknown quantity at this point
Selected dropdownlist item - Call/Fetch data

Hi All.

I have a dropdown list on a web form containing dates. My Question: How can I call data for that selected item(date) from a MySQL database and display it to the user? And more specifically, if that selected date has no data in the data base, I want to be able to display that as well.
I'm looking for a Javascript solution, and if possible a php solution.

Thank You!
DextrousDave is offline   Reply With Quote
Old 03-09-2012, 04:40 PM   PM User | #2
blaze4218
Regular Coder

 
Join Date: Apr 2005
Location: Texas
Posts: 448
Thanks: 24
Thanked 63 Times in 63 Posts
blaze4218 is an unknown quantity at this point
In your javascript code:
1)query the value of the input date
2)using ajax, post the value of step 1 to your php code
3)using ajax and a callback function, retrieve the MySQL data (preferably in JSON or XML format)
4)if a value of false is returned supplant an explanitory string into your data variable
5)insert data into your DOM

In your php code:
1)test the value sent from ajax, and strip, or convert any characters that could be used to exploit security holes
2)apply necessary conversions to the data so that it corresponds to how you structured your database
3)connect to your MySQL to retrieve the necessary records
4)if records are not already structured as JSON or XML, convert them to one of these formats for transmission
5)post the record back to your ajax on the clients browser

Your welcome
__________________
Allwisend bin ich nicht, doch viel ist mir bewursst
-Goethe
blaze4218 is offline   Reply With Quote
Users who have thanked blaze4218 for this post:
DextrousDave (03-11-2012)
Old 03-11-2012, 02:51 PM   PM User | #3
DextrousDave
New to the CF scene

 
Join Date: Mar 2012
Location: South-Africa
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
DextrousDave is an unknown quantity at this point
Thank You Blaze 4218, I will try it and see if I can land it.
Appreciate
DextrousDave is offline   Reply With Quote
Reply

Bookmarks

Tags
<html>, <script>

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:42 AM.


Advertisement
Log in to turn off these ads.