Click to See Complete Forum and Search --> : Use onClick with VBscript !


h2q1
02-28-2007, 10:03 PM
I have a function as follow:

<!--#include file="connection.asp"-->
<%
sub check()
openConn
set rs=Server.CreateObject("ADODB.Recordset")
sqlText = "SELECT username FROM tblUser"
rs.open sqltext, oConn
rs.Movefirst
Do While not rs.EOF
if request.Form("username") = rs("username") then
response.Redirect("admin_modify.asp")
end if
rs.MoveNext
Loop
end sub
%>

I have a form with :
+ 1 textbox to enter username (name of textbox is username)
+ 2 button is : modify and delete
example with button number 1 :
<input type="button" name="modify" value="modify" onClick="<%call check()%>"

then i run this page, with any data entered, I clicked modify button but it didn't work(nothing happens)...my form have action = "" !
(seriously, when I enter data that have in Database into textbox then press Enter immediately, page admin_modify.asp open ! why? )

somebody help me :(

Sorehead
03-01-2007, 05:15 AM
I am a bit lost with what you are trying to do!!!

<input type="button" name="modify" value="modify" onClick="<%call check()%>"

Anything inside Asp deliminators is proceseds on the server before the page is sent to the user's browser, so...<%call check()%> you are trying to call this function before the page is loaded in the browser. Once the page is loaded the input would look like:

<input type="button" name="modify" value="modify" onClick="">

so hitting the button wont do anything, because there is no instruction for it.
onClick is used by Javascript not VBscript as far as im aware. But even using javascript you still cant call a server side script.

What you need to do is post the form to the page, either the same page or place the asp script in a new page. Forget about using a sub() and just use condtional statements to determine whether its a valid user or not.

buntine
03-01-2007, 06:35 PM
Well, VBScript itself is/was a client-side language, but what you are trying to do defeats the purpose of server-side programming.

Learn about the basics of the concept before you start hacking.

See: www.w3schools.com

Cheers,
Andrew