Computing.Net > Forums > Web Development > Dropdown Box for Multiple Forms

Dropdown Box for Multiple Forms

Reply to Message Icon

Original Message
Name: zzzBrett
Date: February 7, 2006 at 13:56:03 Pacific
Subject: Dropdown Box for Multiple Forms
OS: Windows Server 2003 Ent
CPU/Ram: Intel/1 GB RAM
Comment:

Hi,
Please look at this picture.
http://eportal.ws/form.jpg

I want each of the login buttons to send whatever is selected in the "School" dropdown box as a variable to the action page, just like I would send data in a textbox.

Currently, this is setup with three forms, one for "Student", one for "Teacher", one for "Admin". I can put the school dropdown box in one of the forms, but then it will only work for that one form. I need one dropdown box that will include its data in each of the forms.

Any Ideas?

Thanks,
Brett


Report Offensive Message For Removal

Response Number 1
Name: Michael J (by mjdamato)
Date: February 7, 2006 at 17:33:17 Pacific
Subject: Dropdown Box for Multiple Forms
Reply: (edit)

1st, In the head of your page include the following:

< script language="javascript" >
function setSchool(school) {
document.form1.school.value=school;
document.form2.school.value=school;
document.form3.school.value=school;
}

Note: Set form1, form2, and form3 to the names that you give to each of the three forms.

2nd, in each of the three forms create a hidden field like this:

<input type="hidden" name="school" >

You can change the names of these hidden fields, but you will need to change them accordingly in the script above as well.

3rd, in the select list create an onchange even which will run the function above and populate the hidden fields with the selected values:

< select name="school" onchange="setSchool(this.value);" >

Michael J


Report Offensive Follow Up For Removal

Response Number 2
Name: zzzBrett
Date: February 7, 2006 at 18:31:30 Pacific
Subject: Dropdown Box for Multiple Forms
Reply: (edit)

Thanks!
I will try this and get back to you.

Brett


Report Offensive Follow Up For Removal

Response Number 3
Name: zzzBrett
Date: February 8, 2006 at 13:03:01 Pacific
Subject: Dropdown Box for Multiple Forms
Reply: (edit)

This works great! Thanks Michael.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Dropdown Box for Multiple Forms

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software