...

View Full Version : Initializing additional variable to submit with an onChange



Uncle Ron
01-09-2003, 06:25 PM
Yesterday I had to leave before trying out the responses to actually using the onChange. However after trying the following:

onChange="this.form.submit()"

to submit an <OPTION> within a <SELECT> list (which works GREAT!) I discovered I need another piece of the puzzle.

I need to initialize a variable called 'update2' to a non-null state so that when the form is submitted the PERL script can check if 'update2' is non-null, in which case it will return the completed form for correction.

The original thread id is 12621.

Thanks again to everyone that responded yesterday, and many thanks for any help today.

:) UR

beetle
01-09-2003, 07:39 PM
Put this in the form

<input type="hidden" name="update2" value="" />

Shouldn't that work? If not, is the form POST or GET?

Uncle Ron
01-09-2003, 09:05 PM
You'll have to excuse my long explaination. It's to help me clarify my situation. I'm sure you know all this anyway, but bear with me.

The form (which uses the post method) has three submit buttons. CGI submits all the values in the form but only the value of the actual submit button that was clicked. Additional submit button values are not passed through CGI. OK, I think I'm clear. Here is the bit that sets up the submit buttons at the page bottom. (This little bit is brought into each page as needed. Keeping in mind that every page on this site is created dynamically by PERL scripts.)

sub PFFooter
{print "<TABLE cellspacing=0 align=center>";
print " <TR><TD height=20>&nbsp;</TD>";
print " <TR><TD align=center>";
if($update1)
{print "<INPUT class=sm type=submit name=update1 value=\"$update1\">";
}
if($update2)
{print "<INPUT class=sm type=submit name=update2 value=\"$update2\">";
}
print "<INPUT class=sm type=submit name=exit value=\"$exit\">";
print "<INPUT type=hidden name=exitto value=\"$exitto\">";
print "</TD>";
print "</TABLE>";
print "</FORM>";
print "</BODY>";
print "</HTML>";
PrintTag
}


The value of update1, update2 and exit are set at the start of the script like this:

$update1 = 'UPDATE';
$update2 = 'GET GROUP';
$exitto = 'menuMaster.cgi';
$exit = 'EXIT WITHOUT CHANGE';

This works great as long as you actually click on the submit buttons. As you know I'd like JavaScript to submit the page when an onChange occurs (which you've shown me how to do), it's just a matter of getting it to submit a value for update2 when the event fires.

Thanks,
UR:)

PS. update1 and update2 are in 'if' statements to allow for screens that only need one other button besides the EXIT button.

beetle
01-09-2003, 09:22 PM
Hmm, it feels like we are working the symptom and not the problem.

Why does the receiving Perl script NEED a blank value for update2 if update1 is pressed?

Uncle Ron
01-10-2003, 12:08 AM
Beetle,

OOPS we're passing each other. When the script is requested all values are null. When the onChange is executed all three of the submit buttons are still null. I need a way to make update2 something other than null, like '1', for instance.

Then when the form is submitted, update1 will be null, update2 will be 1 and exit will be null. That way the PERL script will "know" that a request to retreive a group from the database has been submitted.

When update1 = 1, the script updates the data base and when exit = 1 then the script exits to the script defined in $exitto.


Thanks in advance for hanging in there with me. I really appreciate your time and effort.

UR:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum