Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run Code on same form from Button Click

Posted on 1998-09-11
9
Medium Priority
?
253 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:rogerb082098
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:raoool
ID: 1854958
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
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854959
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>

0
 

Author Comment

by:rogerb082098
ID: 1854960
Java Script no good, I need to be able to do this with VB Script.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:shez
ID: 1854961
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()">
0
 

Author Comment

by:rogerb082098
ID: 1854962
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

0
 

Accepted Solution

by:
shez earned 240 total points
ID: 1854963
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:
<%
select case btn1
   case "value1"
      script
   case "value2"
      script
end select
%>
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854964
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>
0
 

Expert Comment

by:shez
ID: 1854965
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.
0
 

Author Comment

by:rogerb082098
ID: 1854966
That'll do.


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question