Jump to content

Select Form - Populated Onchange - Save selected variables


lunny

Recommended Posts

Ok what I would like to do is have a select form which lists all my registered members which is no problem.

 

What I would like is then that when they select a member below it information appears regarding that user. So ive looked into this and what id like to use is the javascript function onChange(); and div tags.

 

For example I found this code online which im trying to edit to my needs :

 

<html>

<head>

<title>Flower Order Form</title>

 

</head>

 

<body>

<h3>Flower Order Form</h3>

<form action="processorder.php" method="post">

 

<select id='numflowers'

onChange="javascript: ShowMenu(document.getElementById('numflowers').value,'divColor', 6);">

        <option value='0'>Number of Flowers

        ...

        <option value='5'>6

        ...

        //whatever number of members

 

</select>

 

 

<div id='divColor1' style="display: none;">

                //Display Database select statement info

</div>

 

<br>

</form>

 

</body>

</html>

 

This above code looks messy but it works as intended, the only thing i cant figure out is I need to save the value of currently selected value so i can query my database with that.

 

i.e in php $value = select.value etc..

Link to comment
Share on other sites

Yes,  you do use Javascript for the onchange event.  You should try posting this in the Javascript forum.

 

Additionally you should do some learning on your own as Javascript can become quite messy and complicated in the hands of a novice.

 

A link to the O'Reilly book I used to learn Javascript:

http://www.amazon.com/JavaScript-Definitive-Guide-David-Flanagan/dp/0596101996/ref=sr_1_4/103-2697599-1496625?ie=UTF8&s=books&qid=1178131946&sr=1-4

 

A link to w3schools Javascript tutorial, which I refer to constantly when I don't have the O'Reilly book handy:

http://www.w3schools.com/js/default.asp

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.