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.
juven14Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
Only thing I would know is to use:

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

But why do you need to change the name anyhow?

-r-
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?
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.
RoonaanCommented:
I think you can use":

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

-r-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
juven14Author Commented:
Thanks, this worked perfect.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.