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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a Call from onclick

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
hello,
I am trying to pass parameters from input boxes to some vb that I then want to run via a button onclick methos ,how can I do this ?

so far:

<BODY>
<p><INPUT type=Textbox name=servername></P>
<p><INPUT type=TextBox name=username></p>
<p><INPUT type=textbox name=password></p>
<INPUT type=button name=b1 onclick="<% Call GetServerDetails(servername, username, password)%>">
</BODY>

but I get the error syntax error.
how would I go about doing this ?

than kyou
 
Try this:

<BODY>
<form name="f1" method="post" acttion="next.asp">
<p><INPUT type=Textbox name=servername></P>
<p><INPUT type=TextBox name=username></p>
<p><INPUT type=textbox name=password></p>
<INPUT type=button name=b1 onclick="GetServerDetails(document.f1.servername.value, document.f1.username.value, document.f1.password.value)">
</form>
</BODY>
 
Is your GetServerDetails client or server side function? You need to put all the inputs in the form so you can submit it to your GetServerDetails function.
 
server.

my sub is :

Sub GetServerDetails(servername, username, password)
Dim oWMI
Dim sURL
Dim objLocator
Dim strServer
Dim strusername
Dim strpassword
strServer = servername
strusername = username
strpassword = password

Set objLocator = server.CreateObject("WbemScripting.SWbemLocator")
Set oWMI = objLocator.ConnectServer(strServer,"root\cimv2",strusername,strpassword)

when I try :
<BODY>
<form method="post" name="s1" action="./serverinfo.asp">
<p><INPUT type=Textbox name=servername></P>
<p><INPUT type=TextBox name=username></p>
<p><INPUT type=password name=password></p>
<INPUT type=button name=b1 value="Click" onclick="GetServerDetails(document.s1.servername.value, document.s1.username.value, document.s1.password.value)" >
</FORM>
</BODY>

I get error at line onclick....
 
I believe that when you use the onClick event that it works client-side. If you want it to work server side, I think you should first submit it to another page (or to itself, it doesn't matter) and then run it.

Essentially, get rid of the onclick event on this page. Then, on the next page, just do something like:
Code:
If len(Request.Form("b1")) then
'run your sub here
End If

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
I've tried this ,but its not working.

I am submitting the form to the next page,
I try to do a
response.write request.querystring("servername")

but nothing is there ?
 
Shoud be request("servername")

Not request.querystring("servername")

 
Why are you using Request.Querystring? If you are trying to retrieve the servername variable from the first page, wouldn't it be Request.Form("servername")? That is why Kendel put the form in your code, so that you could then POST your variables to the next page (as opposed to GET which would put them in the querystring).

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
We all have those... Mine usually involve temporary brain freezes... [lol]

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top