juven14
asked on
use onchange to rename select
I have a select:
<select name="type" id="type">
<option value="1">Name</option>
<option value="2">Name</option>
<option value="3">Name</option>
<option value=''ALL">All</option>
</select>
How can I change the name from type to othertype by the user selecting all.
I have tried onchange but my knowledge of javascript is extremely poor.
<select name="type" id="type">
<option value="1">Name</option>
<option value="2">Name</option>
<option value="3">Name</option>
<option value=''ALL">All</option>
</select>
How can I change the name from type to othertype by the user selecting all.
I have tried onchange but my knowledge of javascript is extremely poor.
ASKER
I have a list of subcategories that are used to search a subcategory field and have another field that searches all categories.
Cateogory Parent
1 0
2 1
3 0
4 2
5 1
The search looks for categories via:
select name = type
category like% type
I have added another field that will search by parent, ie select name=parent
parent like% parent
How can I get a value from the option to change the name?
I.e.
<select name=type>
<option value=1 id=type>subcategory 1</option>
<option value=2 id=type>subcategory 2</option>
<option value=1 id=parent>ALL</option>
</select>
I can't use the value field so I'm guessing that it is possible to switch the name with the option id value.
Cateogory Parent
1 0
2 1
3 0
4 2
5 1
The search looks for categories via:
select name = type
category like% type
I have added another field that will search by parent, ie select name=parent
parent like% parent
How can I get a value from the option to change the name?
I.e.
<select name=type>
<option value=1 id=type>subcategory 1</option>
<option value=2 id=type>subcategory 2</option>
<option value=1 id=parent>ALL</option>
</select>
I can't use the value field so I'm guessing that it is possible to switch the name with the option id value.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, this worked perfect.
<select name="type" id="type" onchange="this.name='other
But why do you need to change the name anyhow?
-r-