One form - 3 buttons

Issues related to forms.
Post Reply
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: One form - 3 buttons

Post by alex4orly »

Thanks Baconfries,

If you look up at the top, I have already found this
Ayyway, thanks again
User avatar
BaconFries
 
 
Posts: 5364
Joined: Thu Aug 16, 2007 7:32 pm

Re: One form - 3 buttons

Post by BaconFries »

Yes I know, my suggestion was if you require help on how to use then contact the original author of the script at the page....
https://www.rgagnon.com/jsdetails/js-0018.html
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: One form - 3 buttons

Post by alex4orly »

Thanks, I didn't try it yet - I have more problems with my other topic
How to make a Dialog to be Modal....

I tried everything, maybe you can help me with it here

https://www.wysiwygwebbuilder.com/forum ... 07#p424107

Cheers
User avatar
Pablo
 
Posts: 21712
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: One form - 3 buttons

Post by Pablo »

So, I am not clear - Can any of the 3 buttons become the submit and just call another page?
Yes! By using the script you suggested yourself.

Step 1
add 2 extra pages, so you have a total of forms with different email addresses. Those pages will be the destination pages for form action you are going to control via the script.

Step 2
Modify the 'submitFunction' script so the click of each button will modify the action of the form (and submit it)
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: One form - 3 buttons

Post by alex4orly »

I implemented the following code (ignoring the submit of the email for now)

<script type="text/javascript">
function submitFunction(i)
{
if (i==1)
{
// This next call, loads the page into the whole browser screen, NOT a popup dialog
window.location = "https://communitylifestyleaccommodation ... rship.html"

// This call, loads it as a dialog popup - BUT it is NOT Modal - can't find in WWB properties where to set that to be a Modal page
var myWindow = window.open("https://communitylifestyleaccommodation ... rship.html", "", "width=800,height=650");

}
if (i==2)
{
window.location = "";
}
if (i==3)
{
window.location = "";
}
//document.theForm.submit();
}
</script>
User avatar
Pablo
 
Posts: 21712
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: One form - 3 buttons

Post by Pablo »

Sorry, but this is not correct.
You will need to change the action property of the form, like in the original script.

This is what you wrote:

Code: Select all

<SCRIPT>
function submitFunction(i) {
if (i==1) document.theForm.action=
"http://www.company.com/cgi-bin/cgi1.cgi";
if (i==2) document.theForm.action=
"http://www.company.com/cgi-bin/cgi2.cgi";
if (i==3) document.theForm.action=
"http://www.company.com/cgi-bin/cgi3.cgi";
document.theForm.submit()
}
</SCRIPT>

<FORM NAME="theForm">
<INPUT TYPE="button" VALUE="Submit 1" onClick="submitFunction(1)">
<INPUT TYPE="button" VALUE="Submit 2" onClick="submitFunction(2)">
<INPUT TYPE="button" VALUE="Submit 3" onClick="submitFunction(3)">
</FORM>
It looked like you understood me after my first reply and now you are going into a complete different direction!
Please stick the original idea.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: One form - 3 buttons

Post by alex4orly »

OK, When I cahneg it back to the original, my code looks like the below segment - But, when I click the button "Membership" nothing happens. I placed an alert() inside the if(i==1) and it shows up when I click the button

<script type="text/javascript">
function submitFunction(i)
{
if (i==1)
{
document.theForm.action="https://communitylifestyleaccommodation ... rship.html";
}
if (i==2)
{
document.theForm.action= "";
}
if (i==3)
{
document.theForm.action= "";
}
document.theForm.submit();
}
</script>
User avatar
Pablo
 
Posts: 21712
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: One form - 3 buttons

Post by Pablo »

There is an error in the script:

Code: Select all

alert(Hello dialog);
should be:

Code: Select all

alert('Hello dialog');
Also the form pages should be PHP.
WWBman
 
 
Posts: 917
Joined: Fri Jan 08, 2010 6:10 pm

Re: One form - 3 buttons

Post by WWBman »

Here is a sample of what's required (I think!).
I thought you might prefer 3 payment pages, if not just delete 2 and 3 and adjust the success page entries.

http://www.mediafire.com/file/abqb3odk1 ... m.wbs/file

EDIT:
I tested it on a local server so you might need to change the URLs in submitFunction function.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: One form - 3 buttons

Post by alex4orly »

Hello WWBman

In the meantime, I got more details from the Payment Gateway people
At the end of processing the money transaction. the Gateway sends an email with all the details to a nomiated email address, so in fact I do NOT need to process any form at my end.

Therefore the Welcome page with the 3 buttons doesn't need any special thing, each of the 3 buttons is calling a different WWB Object with a specific description of Membership, Donations, Raffle tickets.

My only remaining problem at the momemnt is that as it stands now, when the transaction is done, the visitor is left on a blank screen... This is of course wrong and I am looking for a way to get back to the front screen of the website

Thanks
Post Reply