Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checked value of second select changes on first select value 1

Status
Not open for further replies.

siituser

Programmer
Sep 30, 2002
67
CA
Hi there, I've seen some examples that are close but not exaclty what I'm tring to do.

I've got 2 select drop downs for choosing a date range. (FROM: and TO:) Each select has a list on days in the month 1 to x (depending on how many days).

When the user selects the FROM date, I want the date in the second select box to change to the date selected.

Example, user selects the 20th, the second select should change to the 20th as well.

Has anyone got an example of something like this?

Thank you in advance.
 
Code:
function synchBoxes()
{
  //This code assumes that the options are value="1","2"...
  var source = window.document.myForm.from;
  var target = window.document.myForm.to;
  
  target.selectedIndex = source.selectedIndex;
}

Change the select tag for from to:
<select name="from" nChange="synchBoxes();return false;">

--Chessbot

The program didn't do anything wrong; it did exactly what you told it to!
 
Awesome Chessbot - thanks for that immediate response!
 
typo:
change nChange=.. to onChange=..

You're welcome...

Thanks for the star!

--Chessbot

The program didn't do anything wrong; it did exactly what you told it to!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top