Welcome to WebmasterWorld Guest from 50.17.87.126

Forum Moderators: phranque

Message Too Old, No Replies

Problem with the submit function of a form

Originally started with FrontPage, then hand-edited for the javascript

     

ashara76

9:51 pm on Dec 16, 2009 (gmt 0)

5+ Year Member



When I originally created this page, I used the FrontPage Form Wizard. It included a lot of unnecessary code which I was able to clean up later when I discovered this format wouldn't work with the javascript that I needed it to include. The rest of the form works beautifully, but when I pasted it back into my original FrontPage the Submit button fails to work. I am publishing this website for the first time today, so I don't know if it worked before I did my editing - I have a feeling not.

I am including the original FrontPage form code, omitting the javascript and actual form questions as they are unnecessary at this point.

<FORM METHOD="POST" ACTION="../_derived/nortbots.htm" onSubmit="location.href='../_derived/nortbots.htm';return false;" webbot-onSubmit webbot-action="--WEBBOT-SELF--">
<!--WEBBOT BOT=SaveResults S-Email-Format="TEXT/PRE" S-Email-Address="myemail@mysite.net" B-Email-Label-Fields="TRUE" B-Email-ReplyTo-From-Field="TRUE" S-Email-ReplyTo="UserEmail" B-Email-Subject-From-Field="TRUE" S-Email-Subject="Truck Quote" S-Builtin-Fields startspan
--><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" i-checksum="43374" endspan --><blockquote>

</blockquote>
<INPUT TYPE=SUBMIT VALUE="Submit Form">
<INPUT TYPE=RESET VALUE="Reset Form">
</form>

I am completely confused by the "../derived/nortbots.htm" reference, this was something FrontPage created. Same with the ' onSubmit="location.href='../_derived/nortbots.htm';return false;" '

Was I supposed to create a derived folder? A nortbots.htm page? If so, what is this page to include? Any help would be appreciated.

rocknbil

11:13 pm on Dec 16, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome aboard ashara76, I can't help you much with the F.P. junk - err, stuff - but there are some F.P. developers around here that might see this. I can, however, tell you a little of what's happening. I'm just going to pull out the non-F.P. stuff, the things that "make sense."

Let's look at a "normal" form and compare it with yours. This may seem like a long way around the fence, but it's all relevant as you will see.

<form method="post" action="anywhere.cgi">
<input type="submit" value="submit">
</form>

This will post all the data in the form to "anywhere.cgi". Now let's add some Javascript. Our Javascript will manage the form submit, so we will pass a reference of it to the JS.


<form method="post" action="anywhere.cgi" onsubmit="return checkForm(this);">
<input type="text" name="fname" id="fname" value="">
<input type="submit" value="submit">
</form>
<script type="text/javascript">
function checkForm(form) {
if (document.getElementById('fname').value=='') {
alert('The name is required');
}
else { form.submit(); }
return false;
}
</script>

On submit, the form object ("this") is passed to the function checkForm and is stored in the variable "form." If the fname field is blank, it will alert the user, otherwise the Javascript submits the form with the line "form.submit()."

But what stops the submit button from submitting the form, hence doing it twice? The "return false" from this function tells the browser NOT to do it's natural action, submit the form.

So, now let's look at yours:

<FORM METHOD="POST" ACTION="../_derived/nortbots.htm" onSubmit="location.href='../_derived/nortbots.htm';return false;">

So whatever is going on, this form will never submit. The form action is irrelevant because the return false says "no, don't submit the form, do what I tell you in the onSubmit handler." It will just redirect to "../derived/norbots.htm" and none of the values will be passed to whatever "norbots.htm" is - and being a static page, it wouldn't do anything with it anyway.

I'd say, in the absence of any other info, this mess might have something to do with this:

webbot-onSubmit webbot-action="--WEBBOT-SELF--"

in which case Front Page Extensions are doing something to automate the form processing. That I can't help you with.

Edit: Hah. Do a G search for notbots.htm, this is something that's "out there" with F.P.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month