Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in passing values

Status
Not open for further replies.

RycherX

Programmer
Mar 18, 2002
20
0
0
US
I have a drop down list box name ListBoxURL in my JSP.
The variable Choice is read into my javascript correctly only if it is one word. If the user makes a selection choice that has 2 words like
"James No", only James will be read in as the Choice. How can I fix this problem?

var Choice = document.myform.ListBoxURL.options[document.myform.ListBoxURL.selectedIndex].value;
 
could you make the two words into one using replace()

replace the space (" ") with underline("_") or other character.
Eric

Starting GA/AL Focus User Group (FUSE) in Atlanta. See IBI website for usergroup info or contact me at eric.searing@wcom.com.
 
Pls find the attached code which replaces the character in the text box

Pls see the from one of the site:

"Internet Explorer 5.5's replace() function supports more features than version 5.0's. In IE 5.0, the replace() function takes two parameters: a regular expression and a replacement string. In IE 5.5, the function takes two parameters as well, but the second one is a handling function that does the replacement in a more elaborated manner. "

Code:

function replaceChars(entry) {
out = "a"; // replace this
add = "z"; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.subform.text.value = temp;
}

<form name=&quot;subform&quot;>

<input type=text name=text size=40 value=&quot;abcdabcd&quot;><br>
<input type=button name=action value=&quot;Done!&quot; onClick=&quot;replaceChars(document.subform.text.value);&quot;>



</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top