Lunarpages Web Hosting Forum

Author Topic: Form validation and actions  (Read 1964 times)

Offline amadorer

  • Trekkie
  • **
  • Posts: 15
Form validation and actions
« on: April 13, 2005, 07:46:49 PM »
Hi all,

Need an advice/help

I'm trying to execute some code just before the FORM action takes place

This is the code I have:

<script language="JavaScript1.1">

function doCheckout() {
window.alert("You are about to be transferred to Paypal secure web site to complete the order - this is a completely secure process, if you have any questions, don't hesitate to email us to services@cafelena.com");

window.alert("Please wait until Paypal secure window comes up");
document.all.paypalCheckout.submit();
this.navigate("index.jsp");
return true;

};

</script>
...
<form id="paypalCheckout" name="paypalCheckout" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">

   Some stuff here...

<input type="button" onClick="doCheckout();">
</form>

The problem I have is that for some reason, not all the browsers render the code as expected, this is, once the user clicks on the "submit" button, then the function doCheckout must be called to show a couple of messages to the user and finally opens a new window with Paypal credit transaction

If I tested this in my lap or desktop, it works well, but if another one tests it, the messages declared in the function are shown (that means the function is being called), but within the function a call to the submit of the form is made to open a new window with Paypal stuff in, this is what is not always happening, just after the messages are shown and the user clicks on "Ok" button to them, the new window call with Paypal is not opened

Some ideas or explanation on how to deal with stuff like this ?

If all above is a mess, in short this is it:

A form with no Submit type button on it, instead of that, a simply Button type button, that when is clicked, it calls a function that displays a couple of messages and makes the call to the form.submit() in order to have the form to process the "action" statement declared on it

Any advice on how to implemente this ? does this has to do with the script version I'm using in the declaration of the <Script> tag ? (I put Javascript 1.1)

Thks in advance,
Regards,
Erick

Offline varianet

  • Spaceship Captain
  • *****
  • Posts: 103
    • http://www.varia.net
Form validation and actions
« Reply #1 on: April 21, 2005, 02:57:57 AM »
Just a note:

as far as I know, not all browser (settings) support/allow JS.

I'd put the submit button on the form.
Unless you state on page that JS is needed to render it.

You can still have JS code executed, on submitting,
before form data is sent to be processed.
I need a Java break.