|
-
Aug 4th, 2004, 10:33 AM
#1
Thread Starter
Lively Member
Problem with <Button onclick=>
I am using VBScript and I have the following code on an ASP page.
Code:
<button onclick="Test;">Test</button>
<%Sub Test%>
<p>Hello</p>
<%End Sub%>
All I am trying to do is learn how to call a sub when the "Test" button is clicked. I have not been able to find an example of this.
Any help would be greatly appreciated.
Last edited by CT_Eagle; Aug 4th, 2004 at 12:44 PM.
-
Aug 4th, 2004, 10:54 AM
#2
Member
<Script language="VBScript">
Sub Test
Document.Write("Hello")
End Sub
</script>
<button onclick="Test">Test</button>
Is there any reason that you can't use this?
-
Aug 4th, 2004, 11:01 AM
#3
Thread Starter
Lively Member
Thanks for the reply japshire.
I already have some server side scripts on the page that are working correctly. If I add "<Script language="VBScript">", they no longer work.
Any other thoughts?
-
Aug 4th, 2004, 11:51 AM
#4
Member
I not sure that I understand where your point of failure is.
Unfortunately I use asp.net and just a little vbscript, so I may not be very much help.
Could you possibly provide some code.
This works so I'm not sure exactly what you have.
*****************************************************
<html>
<head>
<Script type="text/vbscript">
Sub Test1
Document.Write("Hello from Test1!")
End Sub
</script>
<title>Untitled Document</title>
</head>
<body>
<%
Dim i
For i = 0 TO 5
Response.Write("<font size=" & i & ">Pass" & i & "</font><br/>")
Next
%>
<button onclick="Test1">Test1</button>
</body>
</html>
-
Aug 4th, 2004, 12:28 PM
#5
Thread Starter
Lively Member
Thanks again for your response japshire. Your last response was successful in getting a sub to execute with the press of a button.
I have the following code(including how you demonstrated how to get a button to execute a sub) on an ASP page:
Code:
<html>
<head>
<Script type="text/vbscript">
Sub Test1
Document.Write("Hello from Test1!")
End Sub
</script>
<title>CSTools - Organizations</title>
</head>
<body>
<%
Dim strConnect, strCompanyName
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.RecordSet")
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath("cstoolsdb.mdb")
objConn.open strConnect
strcompanyname = request.querystring("companyinfo")
objRS.open "SELECT * FROM tblcompanies WHERE companyname = '" & strcompanyname & "'",objConn
%>
<%fillfields%>
<%Sub fillfields%>
<p align="center"><font size="6"><b><u><%=request.querystring("companyinfo")%></u></b></font></p>
<p><font size=4><b>Catagory:</b> <%=objRS("catagory")%></font></p>
<p><font size=4><b>ID:</b> <%=objrs("id")%></font></p>
<p><font size=4><b>Billing Address:</b> <%=objrs("billingaddress")%> <b>Shipping Address:</b> <%=objrs("shippingaddress")%></font></p>
<p><font size=4><b>City:</b> <%=objrs("city")%></font></p>
<p><font size=4><b>State\Province</b> <%=objrs("stateorprovince")%></font></p>
<p><font size=4><b>Postal Code:</b> <%=objrs("postalcode")%></font></p>
<p><font size=4><b>Country:</b> <%=objrs("country")%></font></p>
<p><font size=4><b>Modem:</b> <%=objrs("modemphoneno")%></font></p>
<p><font size=4><b>Suffix:</b> <%=objrs("suffix")%> <b>Logon:</b> <%=objrs("logon")%> <b>Password:</b> <%=objrs("password")%></font></p>
<p><font size=4><b>Navy Issues:</b> <%=objrs("navyissues")%> <b>Associate Membership:</b> <%=objrs("associatemembership")%></font></p>
<%End Sub%>
<%
objRS.close
set objRS = Nothing
objConn.close
set objConn = Nothing
%>
<button onclick="Test1">Test1</button>
</body>
</html>
What I want the button to do is execute the sub "fillfields" when it is clicked. Any ideas on how to accomplish that would be greatly appreciated.
-
Aug 4th, 2004, 02:10 PM
#6
Member
I'm not sure that you can do it that way.
The reason I say that is everything in <%%> is being processed server side while your button onclick event is client side. As far as your button is concerned fillfields has never existed.
I don't know that I would want to but if you keep everything client side then I would just place your displayed info in a form and process it like this.
*****************************************************
<html>
<head>
<Script type="text/vbscript">
Sub Test1
Document.myInfo.pCode.value = "77777"
End Sub
</script>
<title>Untitled Document</title>
<link href="testing.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="myInfo">
<label id="Label1">Postal Code:</label> <input name="pCode" style="Border: none;" type="text"><br/>
<button onclick="Test1">Submit</button>
</form>
</body>
</html>
-
Aug 6th, 2004, 10:01 AM
#7
Thread Starter
Lively Member
"fillfields" is a sub that I have on the page itself. It is how I "populate" the page with the results from the database. It correctly gets the data from the database when the page is initially loaded. The problem is calling that sub when I change the customer name.
I cannot keep everything client side because the database is located server side.
-
Aug 14th, 2004, 09:48 AM
#8
Lively Member
Hi CT_Eagle,
did u re-submit/reload the page?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|