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>

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.
Who is Participating?
I think you can use":

<select name="type" onchange="[this.selectedIndex].id" >


Only thing I would know is to use:

<select name="type" id="type" onchange="'othertype';">

But why do you need to change the name anyhow?

juven14Author Commented:
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?

<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>

I can't use the value field so I'm guessing that it is possible to switch the name with the option id value.
juven14Author Commented:
Thanks, this worked perfect.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.