Forums
This topic is locked
onclick usage
Posted 29 Aug 2005 12:57:06
1
has voted
29 Aug 2005 12:57:06 peter mill posted:
HiDoes anyone know the correct usage of Onclick.<img src=../images/dmxzone/forum/icon_smile_angry.gif border=0 align=middle>
I have tried for weeks to get it right but always get errors<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
i have looked for references but all the ones i have found dont explain it very well.
thanks
Thunderchild
Replies
Replied 29 Aug 2005 22:49:26
29 Aug 2005 22:49:26 Dave Blohm replied:
What's receiving the action (what's getting clicked) and what do you want to happen when the thing gets clicked?
Doc
Wycked Studios
wyckedstudios.com
Doc
Wycked Studios
wyckedstudios.com
Replied 30 Aug 2005 02:01:04
30 Aug 2005 02:01:04 Rene Bandsma replied:
OnClick is a JavaScript method and can be used as follows:
<pre id=code><font face=courier size=2 id=code>
<a href="javascript:;" onClick="Function">testlink</a>
</font id=code></pre id=code>
There should be a function called Function that is executing the function. In ASP.NET things goes a little bit different. But, as Dave also mentioned: what's getting clicked and what should be processed when clicked??
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
<pre id=code><font face=courier size=2 id=code>
<a href="javascript:;" onClick="Function">testlink</a>
</font id=code></pre id=code>
There should be a function called Function that is executing the function. In ASP.NET things goes a little bit different. But, as Dave also mentioned: what's getting clicked and what should be processed when clicked??
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
Replied 31 Aug 2005 03:49:04
31 Aug 2005 03:49:04 peter mill replied:
I have a button on a dynamic asp/vbscript page. that when clicked. is ment to save the data on the page to the various tables.
the line where the button is <input name="Buy" type="Button" id="Buy" value="Buy It" onClick="Buy" >
and the code to execute.
<%
Sub onClick_Buy
'Setup Order Variables
Dim Orders, OrdID, NewOrdID
Set Orders = Server.CreateObject("ADODB.Recordset"

Orders.ActiveConnection = MM_ABCVitamins_STRING
Orders.Source = "SELECT * FROM Orders"
Orders.CursorType = 3
Orders.CursorLocation = 2
Orders.LockType = 3
Orders.Open()
Orders.Movelast
OrdID = Orders.Fields.Item("OrderID"

NewOrdID = OrdID + 1
Orders.Addnew
Orders.fields("CustomerID"

Orders.Fields("employeeID"

Orders.Fields("OrderDate"

Orders.Update
Orders.Close()
Set Orders= Nothing
' :: OrderDetails Info - OrderDetailID, OrderID, ProductID, Quantity, UnitPrice
' :: OrderDetails Vars :: ODID, NewODID, OrdID, NewOrdID, chid, chQuantity, chprice
' Database access - OrderDetails
Dim OrderDetail, chId, chProduct, chPrice, chQuantity
Set OrderDetail = Server.CreateObject("ADODB.Recordset"

OrderDetail.ActiveConnection = MM_ABCVitamins_STRING
OrderDetail.Source = "SELECT * FROM OrderDetails"
OrderDetail.CursorType = 3
OrderDetail.CursorLocation = 2
OrderDetail.LockType = 3
OrderDetail.Open()
OrderDetail.MoveLast
' ::: OrderDetails LOOP
FOR x = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, x ) <> "" THEN
chProduct=localCart( CARTPNAME, x )
chPrice=localCart( CARTPPRICE, x )
chQuantity=localCart( CARTPQUANTITY, x )
OrderDetail.AddNew
OrderDetail.Fields("OrderID"

OrderDetail.Fields("ProductID"

OrderDetail.Fields("Quantity"

OrderDetail.Fields("UnitPrice"

OrderDetail.Update
If x <= UBOUND( localCart, 2 ) then
OrderDetail.MoveNext
End If
END IF
NEXT
Response.write("DONE"

OrderDetail.Close()
Set OrderDetail = Nothing
End Sub
%>
I have also tried Function onclick_buy
with end function at the end. but i it eirther sitill errors or it doesn't do anything, It just sits there.
The whole issue for using 'Onclick' is that when this page loads it is running all the code when it needs to wait for user intereaction, namely saving the data.
The page is design to give the customer a last look and confirm that they want to buy the products.
but it is saving purchase a purchase order before the customer has a chance to click on the button to confirm. so i am trying to use a onclick for it to wait for the customer.
ok if you need any further info please don't hesitate to ask.
thanks
thunderchild
Replied 31 Aug 2005 21:53:19
31 Aug 2005 21:53:19 Rene Bandsma replied:
I don't know exactly but doesn't functions be declared like this:
<pre id=code><font face=courier size=2 id=code>
<script language="VBScript">
<!—-Function must stay inside these tags -->
</script>
</head>
</font id=code></pre id=code>
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
<pre id=code><font face=courier size=2 id=code>
<script language="VBScript">
<!—-Function must stay inside these tags -->
</script>
</head>
</font id=code></pre id=code>
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>