Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting the value of the select list

Gayatri Sinha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

here the simple code i have.

What I want to do when a person selects something from the select list, onchange its value should be copied into the text box.

<script language="Javascript">
function change(form) {
var m =;
form.textb.value = m;
return true;


<select name="cars" onchange=javascript:change(form)>
<option value="1">Volvo
<option value="2">Saab
<option value="3">Fiat
<option value="4">Audi

<input type="text" name="textb" value="Volvo">


What actually happens here is, suppose if I change the selection to "Fiat", the value in the text box would be "3" not "Fiat". I want the names for the corresponding values that I have given, not the numbers(values)

I know I can change the values itsself from the numbers to the names, but I don't want to do that..
Is there any other way to get the names??

Zip Ped
Ranch Hand
Posts: 336
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic