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!

Auto Handler in JavaScript for Client Side

Status
Not open for further replies.

JohnPham

Programmer
Jul 9, 2001
34
US
Hi all!
I have this problem, Anyone have any idea please help!

<html>
<head>
<Script language=&quot;JavaScript&quot;>
What should I use event handler for this client side in order to have the HTML option select auto load up when reload() the window. Not come back to the very first one in selection but when widow reload I still focus to the same option that I just selected.
function sel_onchange(){

window.reload();

then what should I add here?

}

</Script>
</head>

<body>

<SELECT id=selectUsr name=selectUsr width=&quot;100%&quot; style=&quot;WIDTH: 199px&quot; onchange=&quot;sel_onchange()&quot;>
<OPTION value=&quot;0&quot; > Select User Role</OPTION>
<OPTION value=&quot;1&quot; > Admin</OPTION>
<OPTION value=&quot;2&quot; > Maintainer</OPTION>
<OPTION value=&quot;3&quot; > User</OPTION>
</body></html>

Thank you very much for your time and I am really appreciated your help

John
 

JohnPham,

This sample code will retain your selection.

<html>
<head>
<title>Drop Down Box</title>
</head>

<body>
<%
sel0 = &quot;&quot; : sel1 = &quot;&quot; : sel2 = &quot;&quot; : sel3 = &quot;&quot;
x = request.querystring(&quot;selectUsr&quot;)
if x = 0 then sel0 = &quot;selected&quot;
if x = 1 then sel1 = &quot;selected&quot;
if x = 2 then sel2 = &quot;selected&quot;
if x = 3 then sel3 = &quot;selected&quot;
%>
<form name=&quot;myform&quot;>
Select:
<select name=&quot;selectUsr&quot; width=&quot;100%&quot; style=&quot;WIDTH: 199px&quot; onchange=&quot;changeme()&quot;>
<OPTION value=&quot;0&quot; <%=sel0%> >Select User Role</OPTION>
<OPTION value=&quot;1&quot; <%=sel1%> >Admin</OPTION>
<OPTION value=&quot;2&quot; <%=sel2%> >Maintainer</OPTION>
<OPTION value=&quot;3&quot; <%=sel3%> >User</OPTION>
</select>

</form>

</body>
<script language=&quot;javascript&quot;>
function changeme() {
sel = document.myform.selectUsr.options[document.myform.selectUsr.selectedIndex].value;
document.location=&quot;Myform.asp?selectUsr=&quot; + sel;
}

</script>

</html>

fengshui_1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top