Puneet,
> > Here are the key parts: > > > > Some HTML template looks like this ... > > > > <form id=new_data_form name=new_data_form method=post > > action=myapp.cgi?rm=new_data> > > <input type=hidden name="rm" value="add_record"> > > <input type=hidden name="param1"> > > <input type=hidden name="param2"> > > </form> > > > > <form id=edit_data_form name=edit_data_form method=post > > action=myapp.cgi?rm=edit_data> > > <input type=hidden name="rm" value="edit_record"> > > <input type=hidden name="param1"> > > <input type=hidden name="param2"> > > </form> > > > > in both instance above, you have a url variable (rm) on form action, > and you also are passing the same variable as a hidden field. Why both? > I see this commonly. Pass one or the other... in fact, in case of > forms, don't use url variables at all... just use <input type="hidden" > name="rm" value=whatever value> and make the action really simple such > as <form ... action="myapp.cgi">. If, for some reason, you want to see > the variables in the url, make method="get", but that is messy... Yes, you're correct. I thought it was necessary in both places. It's better to work with hidden parameter at all times if possible. Thanks. > > > > <form id=instant_update_form name=instant_update_form method=post > > action=myapp.cgi> > > <input type=hidden name="rm" value="display"> > > <input type=hidden name="param1"> > > <input type=hidden name="param2"> > > <input type=hidden name="param3"> > > </form> > > > > <form id=main_form name=main_form method=post action=myapp.cgi> > > > > SOME HTML::Template structure here > > > > with ... > > > > <input type=text name="param3"> > > onClick="javascript:add_record()" > > > > .... > > > > and so on > > > > </form> > > > > And the Javascript .... > > > > function add_record() > > { > > var my_form; > > var somevar; > > > > my_form = this.document.forms['new_data_form']; > > somevar = this.document.forms['main'].param3.value; > > > > my_form.param1.value = "add"; > > my_form.param3.value = somevar; /* this is where it happens */ > > my_form.submit(); > > } > > > > and so on for other main display form functions. > > > > Then in the next form, on submit, pass all the cgi params back to > > myapp.cgi?rm=display and finally process. > > this is another common usage that puzzles me... form widgets were > designed to submit forms... I often see folks using Javascript to > submit forms. Unless there is something you are changing on the client > side interactively, this is pointless... just overhead noise. My > philosophy is to keep things as simple as possible and use them mostly > for what they are designed -- less chance of breakage. > > Here is a simple way of doing this... > > in your template, for example, in the edit form... > > <form name="myform" action="myapp.cgi" method="post"> > blah blah blah > <input type="submit" name="action" value="Edit"> > </form> > > and then in your script... > > my $action = param('action'); # assuming you are use-ing CGI.pm > if ($action eq 'Edit') { > ... edit code ... > } elsif ($action eq 'Delete') { > ... delete code ... > } elsif ($action eq 'Add') { > ... > ... > you get the idea Hmm, maybe I don't. Or maybe you didn't completely get my idea. I'll be graphical: my app looks like this: *USER SELECTIONS ON DISPLAY FORM [display form] ------+--> *delete record ---+---> rm=process ------> [display form] (shows many records | ^ from variable | | *like* db's. |--> *new record | this is the | rm=new | KEY motivation!!! | | | | \ | | [new record form] | | | | | \ | | *submit--->--->--+ | | | | |--> *edit record | rm=edit | | | \ | [edit record form] | here, this form may be | | different from the new_record_form \ | (i.e. completely different template) *submit--->--->--+ In the new record form, I need to a new record to what, it may change depending on the display form. Same with edit record, I need to know which record from where. Then I want to end back up at the display form to process and display the changes, where I most certainly have code that looks like: > my $action = param('action'); # assuming you are use-ing CGI.pm > if ($action eq 'Edit') { > ... edit code ... > } elsif ($action eq 'Delete') { > ... delete code ... > } elsif ($action eq 'Add') { > > There can be many variations on the above... a simple way is to create > separate templates for each of the actions, changing the value of > <input type="submit" name="action" value=???> in each template > appropriately. > Yes, of course. So, am I still missing something here? Bill --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003 ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users