Link to home
Start Free TrialLog in
Avatar of rogerb082098
rogerb082098

asked on

Run Code on same form from Button Click

Can I run code on the same form from a button click?
I know how to goto another form and pick up variables, run code etc, but cannot see how to do it on the same form.
I am using FP98 for the HTML and VB Script and IEXP 3.02.
Thanks.
Avatar of raoool
raoool

You can use GET method and some Javascript to pass forms data at the browser. Good starting point at...

www.hotwired.com/webmonkey/javascript/code_library/parse_get/?TW=javascript&category=forms_data
Avatar of sybe
Do you mean something like this ?

<script>
function SomeFunction() {
  document.myForm.myTextfield.value="button clicked";
}
</script>

<form name="myForm">
<input type="text" name="myTextfield">
<input type="button" name="mybutton" value="Click Here" onClick="SomeFunction()">
</form>

Avatar of rogerb082098

ASKER

Java Script no good, I need to be able to do this with VB Script.
you can submit the form to itself:
<form action="sameform.XXX">
or you can add an onclick event to the button:
<input type="button" name="button" value="runit" onClick="name of your sub()">
Shez

Thanks for the answer but this is a form that has already posted data to itself in the way your describe. What I now require is to be able to run Server Side code dependant on which Button is clicked on the Client - which I think is a little more complicated.

Roger

ASKER CERTIFIED SOLUTION
Avatar of shez
shez

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is the same, but now in VBScript

<script>
Function SomeFunction()
  document.myForm.myTextfield.value="button clicked";
End Function
</script>

<form name="myForm">
<input type="text" name="myTextfield">
<input type="button" name="mybutton" value="Click Here" onClick="SomeFunction()">
</form>
you must give all buttons the same name and diffrent values:
<input type="submit" name="btn1" value="value1">
<input type="submit" name="btn1" value="value2">
and then write ASP VBscript somthing like this:
<%
btn1 = Request("btn1")    
select case btn1
    case "value1"
       script
    case "value2"
       script
end select
%>
p.s. you got to add this request line to asp code.
That'll do.