Solved

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

Posted on 2014-09-05
2
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

622 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