How can call a client-side function when open a page

J

Jack

Hello,
<%@ Language=VBScript %>
<%
Response.Write "<form name=form1>"
Response.Write "<SELECT id=select1 name=select1>"
Response.Write "<OPTION value=1>One</OPTION>"
Response.Write "<OPTION value=2>Two</OPTION>"
Response.Write "<OPTION value=3>Three</OPTION>"
Response.Write "</SELECT>"
Response.Write "</form>"
%>
<Script language=JavaScript>
function noselected()
{
form1.select1.value=0
}
</Script>
I want when open the page call function noselected().
Thank you
 
R

Ray at

Jack,

This is a client-side scripting question, not an asp question. But, I
believe one thing that you can do is to just take your code out of the
function block. Either that or call the function from outside of any other
function block.

Ray at home
 
S

swp

Jack said:
Hello,
<%@ Language=VBScript %>
<%
Response.Write "<form name=form1>"
Response.Write "<SELECT id=select1 name=select1>"
Response.Write "<OPTION value=1>One</OPTION>"
Response.Write "<OPTION value=2>Two</OPTION>"
Response.Write "<OPTION value=3>Three</OPTION>"
Response.Write "</SELECT>"
Response.Write "</form>"
%>
<Script language=JavaScript>
function noselected()
{
form1.select1.value=0
}
</Script>
I want when open the page call function noselected().
Thank you

you need to put in a <body> tag, which will either call your
"noselected" function as given above or just directly set the value.
it will look something like this:

<body onLoad="JavaScript:form1.select1.value=0;">
or
<body onLoad="noselected();">

also, the use of "<script language=JavaScript>" is no longer correct.
it should be changed to "<script type=text/javascript>" instead.

hope this helps.

swp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top