PDA

Click to See Complete Forum and Search --> : vbscript or javascript


vkallelil
May 11th, 2001, 05:59 AM
Can these be done in vbscript or do I have to use javascript

1) How do I create a button, so that when pressed it calls a function.The function I want to write would be to save the data, or go back to the previous screen. How would I do that??

2) Can I do validation on a text box to see if the user is entering numeric data??

Thanks

Reggie

JoshT
May 11th, 2001, 06:05 AM
VBscript will work only on IE, while javascript will work on IE and other browsers. (Provided the user has them enabled). You would use the onClick event to run a function when a button is pressed. You would have no problem doing data validation in either language.

vkallelil
May 11th, 2001, 07:24 AM
JoshT,

I wrote this code for the button, but for some reason it would not go into the function Update_Records().

<INPUT name="Update_Records" onclick="Update_Records()" type="Button" value="Update Data">

Function Update_Records_Onclick()

Response.write "Message"

End Function

JoshT
May 11th, 2001, 10:44 AM
You're mixing client and server side code. Do you want to execute your function on the server on on the client?

vkallelil
May 11th, 2001, 12:53 PM
Which Script runs faster?.

What is the syntax for client side. How do I call a function from the client side??

Sastraxi
May 11th, 2001, 02:53 PM
<INPUT name="Update_Records" onclick="Update_The_Records()" type="Button" value="Update Data">

Function Update_The_Records()
Response.write "Message"
End Function

The first didnt work cuz' you called Update_Records. You couldve called Update_Records_Onclick or put nothing at all for it to work.

monte96
May 11th, 2001, 03:50 PM
You won't be able to update a database from client side script. I would suggest changing your button to a submit and onsubmit, call your validation function, before the submit.

You can have the form submit to the same page and put code in the beginning of the page that only runs if the form was submitted You could check the value of say Request.Form("MySubmit"). If it has a value, run the update database code.

ttlai
May 11th, 2001, 04:29 PM
JoshT,

It seems like you're always catching people mixing up client/server scripting. Haha, not bad!

JoshT
May 14th, 2001, 11:10 AM
It seems like you're always catching people mixing up client/server scripting. Haha, not bad!

Yeah, it happens a lot. In real life, I've had fun trying to explain to certain people that you can dynamically generate client scripts with server scripts...