tmueller18
asked on
reading text of select box from users selection
i have a simple html selectbox and i can read the selected value no problem. How do i read the text?
something like this?
Request.Form["AFFX"].Selec tedIndex.T ext ?
im having a complete brain fart today
something like this?
Request.Form["AFFX"].Selec
im having a complete brain fart today
html selectbox?
ASKER
the error
Compiler Error Message: CS0246: The type or namespace name 'AFFX' could not be found (are you missing a using directive or an assembly reference?)
im using HTML to build the selectbox
<select name='Afil1'>
<option value="">- Please select affiliate -</option>
<option value="5517">ABC Affiliate</option>
<option value="5487">adsfdsfasdfff dddfd</opt ion>
<option value="5512">Affiliate ABC</option>
<option value="5515">Affiliate test x</option>
</select>
Compiler Error Message: CS0246: The type or namespace name 'AFFX' could not be found (are you missing a using directive or an assembly reference?)
im using HTML to build the selectbox
<select name='Afil1'>
<option value="">- Please select affiliate -</option>
<option value="5517">ABC Affiliate</option>
<option value="5487">adsfdsfasdfff
<option value="5512">Affiliate ABC</option>
<option value="5515">Affiliate test x</option>
</select>
ASKER
i huess i could do something like this
<option value="5517_ABC Affiliate">ABC Affiliate</option>
and then parse out the name from the value.
would I use indeOf in c# for this?
<option value="5517_ABC Affiliate">ABC Affiliate</option>
and then parse out the name from the value.
would I use indeOf in c# for this?
try this piece of code.
<html>
<head>
<script language="JavaScript">
function getValue() {
alert(document.frmMain.mys el[documen t.frmMain. mysel.sele ctedIndex] .value);
}
function getText() {
alert(document.frmMain.mys el[documen t.frmMain. mysel.sele ctedIndex] .innerHTML );
}
</script>
</head>
<body>
<form name="frmMain">
<select name="mysel">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<br><br>
<input type="button" value="Get Value" onclick="getValue()">
<br><br>
<input type="button" value="Get Text" onclick="getText()">
</form>
</body>
</html>
hongjun
<html>
<head>
<script language="JavaScript">
function getValue() {
alert(document.frmMain.mys
}
function getText() {
alert(document.frmMain.mys
}
</script>
</head>
<body>
<form name="frmMain">
<select name="mysel">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<br><br>
<input type="button" value="Get Value" onclick="getValue()">
<br><br>
<input type="button" value="Get Text" onclick="getText()">
</form>
</body>
</html>
hongjun
javascript will solve your problem.
ASKER
i need this one the server side since items are going into a database
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
NameofControl.Items[Nameof