0

ive a dynamic dropdownlist, which items are retrieved frm db. but when i select an item from the dropdownlist, the item does not stay selected instead the dropdownlist make a postback and stay as default value.

wad shd i do? is there any mtd to get d value selected?

THANK YOU VERY MUCH!

related codes below--

function chktype(){
    document.gt.action = 'add_user.asp?userID='+document.gt.userID.value;   
    document.gt.submit();
}

<select name="type" onChange="chktype();" mandatory='true' class="text">
    <%sql = "select distinct * from t_user_type order by userType"   
        set rs = conn.execute(sql)
        do while not rs.eof%>  
        <option value="<%=rs("userType")%>" <%if request.Form("type") =rs("userType") then response.Write(" selected")%>><%=rs("userType")%></option>
                 <%rs.moveNext 
            loop%>
</select>

Edited by pyTony: fixed formating

Attachments
function chktype(){
	
	document.gt.action = 'add_user.asp?userID='+document.gt.userID.value;
	
	document.gt.submit();
}
 

<select name="type" onChange="chktype();" mandatory='true' class="text">
	<%sql = "select distinct * from t_user_type order by userType"	
		set rs = conn.execute(sql)
		do while not rs.eof%>  
		<option value="<%=rs("userType")%>" <%if request.Form("type") =rs("userType") then response.Write(" selected")%>><%=rs("userType")%></option>
                 <%rs.moveNext 
			loop%>
</select>
6
Contributors
7
Replies
8
Views
11 Years
Discussion Span
Last Post by Sandy Patil
0

i had the same problem.

to my knowledge (im not at my development pc right now) the if statement doesnt like retrieving records from a db and comparing it to a form value.

try making vars of the two that you want to compare, then if it.

not sure if it would work

0

wad do u mean? i dun quite understand.. do u mind sharing n tellin me more?

it wud b great to even provide some eg. hEE~

real thanks... :cheesy:

0

go asp.net, automatic saving values in forms

;) huh?!? im using asp not asp.net.. i dun quite understand wad are u tryin 2 link me to.. haha~ would u prefer to explain more.. cheers~

0

Hello mate,

Having a similar problem myself. The equivelant code works in PHP but ASP doesn't want to know. Did you figure it out in the end?

Cheers

0

hey buddy
do this and it will work
and if it wont let me know
ok


here it goes

listName.options[listName.selectedIndex].value

and then set the action
it will be set

ok
try it and let me know

0

Same problem here mentioned above...
...
I set AutoPostback property of dropdownlist as true...
It takes always first value in the dropdownlist

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.