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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnChange event with multiple fields

Status
Not open for further replies.

bill1one

Programmer
Sep 29, 2004
93
US
I must apologize, I am new to this. I am trying to create a form to search a database. If the value of the SearchData is "Books", I want the value of SearchField to be "15"; otherwise, I want the value of SearchField to be "17".

This is what I've come up with thus far, any suggestions?
<FORM Name="NewItems" ACTION="../TLCScripts/interpac.dll?NewestSearch" METHOD="post">
<INPUT TYPE=hidden NAME=Config VALUE="PAC">
<INPUT Type="hidden" NAME="PeriodLimit" Value="45">
<INPUT type="hidden" name="SearchType" value="1">
<INPUT type="hidden" name="SortField" value="2">
<INPUT type="hidden" name="ItemsPerPage" value="100">
<INPUT type="hidden" name="SearchField">
New Items:<br />
<select name="SearchData" onchange="document.forms[0].SearchField.value=(this.value=="Books)?'15':'17';">
<option value="videorecording-DVD">Movies</option>
<option value="sound recording-CD">Audio Books</option>
<option value="Books">Mysteries</option>
</select>
<INPUT type=submit value="Submit">
</FORM>
 
I guess you're saying that this isn't working. Try putting an extra set of parentheses around the tertiary conditional you've got (this.value=="Books)?'15':'17');">

That's all I see right now. 'hope that helps.

--Dave

 
I'm sorry, I failed to mention that it isn't working in my original post. I guess my problem is that I don't know how to define the SearchField value or pass that value along with the SearchData to the database.

 
First, you probably want to give the SearchField a value initially, in case the user hits Submit without changing the drop-down (and thereby triggering the onchange event).

Second, you have a quotes problem. this.value=="Books should be this.value=='Books'. You need the close quotes and double-quotes inside of double-quotes are a b*tch. Make them single quotes.

Finally, I have never made the ACTION of a form a dll. I usually make it a JSP, where I read in the parameters sent and then do my database updates from there, so I can't help you with that part.

Good luck!

--Dave
 
That works! It's always those small details that trip me up. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top