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.
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.
Do you mean something like this ?
<script>
function SomeFunction() {
document.myForm.myTextfiel d.value="b utton clicked";
}
</script>
<form name="myForm">
<input type="text" name="myTextfield">
<input type="button" name="mybutton" value="Click Here" onClick="SomeFunction()">
</form>
<script>
function SomeFunction() {
document.myForm.myTextfiel
}
</script>
<form name="myForm">
<input type="text" name="myTextfield">
<input type="button" name="mybutton" value="Click Here" onClick="SomeFunction()">
</form>
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()">
<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()">
ASKER
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is the same, but now in VBScript
<script>
Function SomeFunction()
document.myForm.myTextfiel d.value="b utton clicked";
End Function
</script>
<form name="myForm">
<input type="text" name="myTextfield">
<input type="button" name="mybutton" value="Click Here" onClick="SomeFunction()">
</form>
<script>
Function SomeFunction()
document.myForm.myTextfiel
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.
<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.
ASKER
That'll do.
www.hotwired.com/webmonkey/javascript/code_library/parse_get/?TW=javascript&category=forms_data