Javascript Select Value

Tenant

New Member
Messages
13
Reaction score
0
Points
0
Ill display my code first and then describe what im trying to do.

Javascript section
Code:
function ReadForm(obj1) {
   var data_array = obj1.os0.value.split('^');
   var des=data_array[0];
   var amt=data_array[1];
   obj1.os0.value = des;    
}

form code
Code:
<select name="os0">
<option value="2^1">Two to one</option>
<option value="3^2">Three to two</option>
</select>

Last line of the javascript I included is suppose to change the value of os0 when the form is submitted. Before you say use getElementById I will tell you that this is not an option. I am dealing with paypal buttons and this site has over 300 buttons which can not all use the same id. Any help on this one would help out alot.
Edit:
Update:

I finally found a way to do it. For the benefit of anyone looking for this solution in the future here it is.

Code:
var selectBox = obj1.os0;
var selectedItem = selectBox[selectBox.selectedIndex];
selectedItem.value=des;
 
Last edited:
Top