Solved

How do I populate a series of text fields using Javascript based on a pulldown selection

Posted on 2014-09-05
2
140 Views
Last Modified: 2014-09-10
Head out to http://hihatwebdesign.com/vbs/student_insert.php.

What needs to happen is the user can potential select from a list of families in the "family id" pulldown. If they make a selection, all of the corresponding fields are automatically populated with the info corresponding to the family they selected.

Also, I need a button to appear, should they make a selection, that allows them to clear the info, but only the info effected by the "family id" pulldown (address, city, state, zip, phone, cell, email, alt email, home church, subdivision).

What would the Javascript function look like?

I know I need an "on change" dynamic in the pulldown, but I'm lost as far as how to incorporate a MySQL statement in the midst of the Javascript.

What do you think?
0
Comment
Question by:brucegust
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 40306954
for the first one you need to understand ajax and the concept is cascading dropdown
check this threads :
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28032165.html
http://www.experts-exchange.com/Database/MS-SQL-Server/SQL-Server-2005/Q_28031051.html
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_24805634.html
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_23687497.html
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_22665347.html
http://www.experts-exchange.com/Software/Internet_Email/Web_Browsers/Q_24994737.html

for your button : <input type="button" id="buttonID" value="reset fields" />
And in head section :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
jQuery(function($) {
    $("#buttonID").click(function() {
         $("[name='f_last_name'],[name='address'], and so on ,[name='subdivision']").val();
    });
});
</script>

Open in new window

0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40307483
Intro to the basics of jQuery/AJAX, with example showing how to populate a browser document element with information gleaned from the server.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript behaviour different on local machine and network share 11 47
Attach to file (img) a unique id 8 25
Passport Expiry 3 44
Hide cell in a table 2 10
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question