|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
How do I get the value of a SelectedIndex?
See below code <script> function toggleTextBox(){ var x = document.myform.hotOrderList.options; if(x.[this.selectedIndex].value == 'Yes'){ document.myform.txtHotOrderName.style.display = ''; } else{ document.myform.txtHotOrderName.style.display = 'none'; } } </script> Regards, Edmond |
|
#2
|
|||
|
|||
|
This is not ASP, this is JavaScript.
__________________
"You'll never be as perfect as BLaaaaaaaaarche." |
|
#3
|
||||
|
||||
|
this would work:
Code:
if (document.myform.hotOrderList.value == 'Yes') {
|
|
#4
|
|||
|
|||
|
hi
i need to get the value of the dropdown list selectedIndex. With the below code, it gives me an error saying it needs an object. any insight on this problem will be awesome :-) see below <code> <script type="javascript"> function toggle(){ if(document.myform.refreshList.options[document.myform.refreshList.options.selectedIndex].value == 'No'){ document.myform.refreshnum.style.display = ''; document.myform.refreshnote.style.display = ''; } else{ document.myform.refreshnum.style.display = 'none'; document.myform.refreshnote.style.display = 'none'; } } </script> </code> Quote:
|
|
#5
|
||||
|
||||
|
Code:
var s = document.myform.refreshList;
if(s.options[s.selectedIndex].value == 'No'){
__________________
Support requests via PM will be ignored! |
|
#6
|
||||
|
||||
|
in order for this to work, you must have form named "myform" and this
form should have drop down element named "refreshList", case sensitive. if you don't have any of those you will, indeed, get error. |
|
#7
|
|||
|
|||
|
Post the <option> tags as well, please.
Last edited by ChiefWigs1982 : May 14th, 2008 at 09:06 AM. |
|
#8
|
||||
|
||||
|
Ah crap, sorry, I edited your post rather than posting a new one.
Can you respost your code, including the <option> tags? Sorry dude! ![]() |
|
#9
|
|||
|
|||
|
hey.. it's ok
here is the code - see below the dropdown list is reading from db it doesn't have to be.. Code:
<body onload="toggle();">
<form name="myform">
<script>
function toggle(){
var s = document.myform.refreshList;
if(s.options[s.selectedIndex].value == 'No'){
document.myform.refreshnum.style.display = '';
document.myform.refreshnote.style.display = '';
}
else{
document.myform.refreshnum.style.display = 'none';
document.myform.refreshnote.style.display = 'none';
}
}
</script>
<select size="1" name="refreshList" onChange="toggle();" tabindex="3">
<option selected></option>
<%
If refreshList <> "" Then
Response.Write "<option selected>" & refreshList & "</option>"
End If
sql = "Select refresh From refresh Order By id"
set conn = Server.CreateObject("ADODB.Connection")
conn.open "provider=sqloledb;data Source=server;initial catalog=dashboard;integrated security=SSPI;"
set rs = conn.execute(sql)
do while not rs.eof
thisfield = trim(rs(0))
if isnull(thisfield) or thisfield="" then
'
else
response.write "<option>" & thisfield & "</option>"
end if
rs.movenext
loop
%>
</select>
Quote:
|
|
#10
|
||||
|
||||
|
you get error because your form does not contain element
named "refreshnum". add such element and try again. |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > General - Question - Get value of SelectedIndex |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|