PDA

View Full Version : Interactions with inputs and list's


Akito
01-04-2003, 04:59 AM
Here is my problem:

I have a search engine that looks through items. Each item has 2 names. However, I only look at one of the names per search. When the user is searching, he/she uses a INPUT to select which name they want to search in. There is also a drop down list next to each type of name that lists ALL the names for their respective name category (1,2). When the user selects a name in list 2, I want the input radio box to automatically move to the proper name. Example:

[ Search Box ]
[ Search in name A (radio button) ] [ Drop down list with all "name a" items in it ]
[ Search in name B (radio button) ] [ Drop down list with all "name b" items in it ]
[ submit box ]

I hope that makes sense. I did a search, and nothing. I also looked around javascriptkit.com (or whatever that site is called) couldn't find anything. Thank for your help!

Akito
01-05-2003, 03:14 PM
Anybody?

beetle
01-06-2003, 03:24 PM
Yes!<html>
<head>
<title>Form thingie</title>

<script type="text/javascript">

function changeSearch( f, sel, rad )
{
f.elements[sel].selectedIndex = 0;
if ( typeof rad != 'undefined' )
f.elements[rad].checked = true;
}

</script>

</head>

<body>

<form>
<input type="text" name="Search" />
<br />
A <input type="radio" name="AB" id="radioA" value="A" checked="false" onclick="changeSearch( this.form, 'B_Names' );" />
<select name="A_Names" onchange="changeSearch( this.form, 'B_Names', 'radioA' );">
<option>Pick One</option>
<option>Blah</option>
<option>Blah</option>
<option>Blah</option>
</select>
<br />
B <input type="radio" name="AB" id="radioB" value="B" checked="false" onclick="changeSearch( this.form, 'A_Names' );" />
<select name="B_Names" onchange="changeSearch( this.form, 'A_Names', 'radioB' );">
<option>Pick One</option>
<option>Blah</option>
<option>Blah</option>
<option>Blah</option>
</select>
</form>

</body>
</html>

Akito
01-07-2003, 07:06 PM
You are my new best friend. Thanks much.