PDA

View Full Version : cgi script not working


snowball
01-06-2003, 04:36 PM
Hi, can anyone help?

I have a cgi script with a little java code in it which produces a page where the only thing on it is a submit button and a whole load of hidden values in the form. The operation works great, but you sit on this page until you press "Submit". I just want (effectively) to have the button press itself without the user having to do anything.

The usual ..............

<script type="text/javascript">
<!--
document.MYFORMNAME.submit();
// -->
</script>


causes the form to submit over and over again. You'll see in the original (below) that the submit button has an ..... onClick="saveForm(this.form);" ..... command in it, which calls on the saveForm function higher up the page.

I've tried moving those commands down, but if I do nothing happens at all. The page just sits there with an error saying "object does not support this property or method".

So I'm stuck on either a page that just sits there (doing nothing with an error) or a form that resubmits endlessly, rather than the submit once and move on to the next page, which is what the page with the submit button achieves now.

Here's the code ....................



<script language="JavaScript1.1">
<!--
function saveForm() {
document.htmlForm.target="_self"
document.htmlForm.submit
}
//-->
</script>

<FORM METHOD=POST ACTION="$cgiurl" name="htmlForm">
$Account::hidden_variables

<script language="JavaScript1.1">
<!--
if ("$INPUT{'template'}" === "template_2.dat") {
document.write('<input type=\"hidden\" name=\"_file_name_\" value=\"gallery.html\">');
} else {
document.write('<input type=\"hidden\" name=\"_file_name_\" value=\"index.html\">');
}
//-->
</script>

<input type="hidden" name="dir" value="">

<input type="Submit" name="save" value = " $lang::ut5 " onClick="saveForm(this.form);">

</FORM>



If anyone has any other ideas I would be really, really greatful.

Thanks

snow

Grizz2
01-06-2003, 05:02 PM
Well this might be kinda off the wall but suppose you set a counter. Would the form then only submit once?

<script type="text/javascript">
<!--
Var SubmitCounter = 0;
if(SubmitCounter == 0){
document.MYFORMNAME.submit();
SubmitCounter = 1;
}
// -->
</script>

snowball
01-06-2003, 07:42 PM
Thanks for trying ..... but this doesn't work. It just keeps resubmitting and going nowhere.

The problem must have something to do with the fact that there is a onClick command telling it on submit to carry out the routine "saveform".

Any other suggestions ....... greatfully received.

snow