December 06, 2004, 11:07 AM
CHERIJavaScript to divide one variable into two
Good Morning:
I have a html page that I'm allowing multiple selections from a drop down list box. The variable I'm passing to the focus program consists of two fields concatenated together. With Javascript I would like to break this variable into two seperate variables. I know I accomplish this within the focus program but I would like to use Javascript. Has anyone done this before ?
December 06, 2004, 11:21 AM
HåkanGiven you have a separator, you can use the method split:
arrayOfStrings = stringToSplit.split(separator);
H�kan
December 06, 2004, 11:37 AM
CHERII think the problem I'm having is it is not recognizing the value in the select list box. Any thoughts ?
December 06, 2004, 11:54 AM
HåkanThis is what I've used:
var x = document.adj.ACTION.selectedIndex;
var opt = document.adj.ACTION.options[x].value;
Now you can perform your split on the var opt.
H�kan
December 06, 2004, 12:10 PM
CHERIIf I use an alert and display the value of 'x' I do see the number representing the item selected. However, if I use an alert to display the value of 'opt' I do not see a value. I should be, correct ?
December 06, 2004, 02:08 PM
TexasStingrayCHERI
FYI besure that the option does have an actual value= in it. Otherwise you will have to use the text.