Solved

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

Posted on 2014-09-05
2
137 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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
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…
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now