Forms manipulation

I wrote a html script which invokes a CGI script,
in CGI script based on some options, it is going to
create a dynamic form with some input fields like
buttons, checkboxes, etc.  
From this dynamic page, if someone clicks a button or a checkbox, i need to write some code for handling that.
Can you tell me how to check what button has been clicked and where to handle the event?
Shall i take javascript for doing this??

Any suggestions.....

Also in navigating between different forms, is it advisable to write that many htmls coupled with cgi scripts
OR
Do we go for one html with a static page and then handling
the remaining pages dynamically??

Thanks in advance
LVL 1
kirthirAsked:
Who is Participating?
 
DKostovConnect With a Mentor Commented:
>I wrote a html script which invokes a CGI script,
>in CGI script based on some options, it is going to
>create a dynamic form with some input fields like
>buttons, checkboxes, etc.    
>From this dynamic page, if someone clicks a button or a checkbox, i need to write some code >for handling that.
>Can you tell me how to check what button has been clicked and where to handle the event?
>Shall i take javascript for doing this??

>Any suggestions.....

I will start directly with an example. There will be different processing for one
checkbox and couple of buttons. The checkbox calls a java script when you click on
it. For the other two buttons you can verify the value of the hidden
"varWichButton" variable in your cgi. If its value is empty the "btnSubmit" is pressed.
If its value is equal to "1" - the "btnOther" is pressed. In this way you can manage
any other html control.

---------------------------------------------------------------------------------------
<HTML>
<HEAD>
      <TITLE>Sample form</TITLE>
      <SCRIPT LANGUAGE="JavaScript">
            function CheckBtnProc ()
            {
                  window.alert('Checkbox Pressed!');
            }
      </SCRIPT>
</HEAD>
<BODY>
<FORM NAME="frmYourForm" METHOD="POST" ACTION="/VirtDir/YourCgi.exe">
      <INPUT TYPE="HIDDEN" NAME="varWichButton" VALUE="">
      <input type="SUBMIT" name="btnSubmit" value="Submit">
      <input type="button" name="btnOther" value="Other"
            OnClick="this.form.varWichButton.value ='1';this.form.submit();">
      <input type="checkbox" name="btnCheck"  checked  OnClick="CheckBtnProc ();">
</FORM>
</BODY>
</HTML>
----------------------------------------------------------------------------------------

>Also in navigating between different forms, is it advisable to write that many htmls >coupled with cgi scripts
>OR
>Do we go for one html with a static page and then handling
>the remaining pages dynamically??

It depends on you, but on your place I will choose the first one method,
because in many cases using static html template you can make further changes
only on it, without change (or recompile) your cgi. Of course that's not
a rule.


Hope this helps :)

0
 
MoondancerCommented:
GREETINGS!

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0
All Courses

From novice to tech pro — start learning today.