Solved

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

Posted on 2014-09-05
2
136 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
Comment Utility
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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now