Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2013, 11:03 AM   PM User | #1
nani_nisha06
Regular Coder

 
Join Date: Oct 2012
Location: mother land --india
Posts: 159
Thanks: 37
Thanked 2 Times in 2 Posts
nani_nisha06 is an unknown quantity at this point
Need help to create 2 submit button to execute 2 different scripts

Hi Frnds,

I have form and it needs 1 "save" button & 1 "close" button which need to link to 2 different scripts, Save.php & close.php.

Please help me complete these requirement.


Regards,
Nani

Last edited by nani_nisha06; 02-04-2013 at 12:51 PM..
nani_nisha06 is offline   Reply With Quote
Old 02-04-2013, 11:59 AM   PM User | #2
niralsoni
Regular Coder

 
Join Date: Mar 2008
Location: London
Posts: 129
Thanks: 1
Thanked 31 Times in 31 Posts
niralsoni is an unknown quantity at this point
html will look something like this (calling two different JavaScript functions on two buttons) -
Code:
<form name="MyForm"> 
.....
.....
<input type="button" value="Save" onclick="return saveData()">
<input type="button" value="Close" onclick="return closePage()">
.....
.....
</form>
Then in the JavaScript function, set the action attribute of form as -
Code:
function saveData() {
  // logic for validating form data etc.
  // if all successful
  {
    MyForm.action = "save.php";
    MyForm.method = "POST";
    MyForm.submit();
    return true;
  }
  return false;
}

function closePage() {
  MyForm.action = "close.php";
  MyForm.method = "POST";
  MyForm.submit();
  return true;
}
Hope it helps you out...

Regards,
Niral Soni
niralsoni is offline   Reply With Quote
Users who have thanked niralsoni for this post:
nani_nisha06 (02-04-2013)
Old 02-04-2013, 12:47 PM   PM User | #3
nani_nisha06
Regular Coder

 
Join Date: Oct 2012
Location: mother land --india
Posts: 159
Thanks: 37
Thanked 2 Times in 2 Posts
nani_nisha06 is an unknown quantity at this point
Then in the JavaScript function, set the action attribute of form as -
Code:
function saveData() {
  // logic for validating form data etc.
  // if all successful
  {
    MyForm.action = "save.php";
    MyForm.method = "POST";
    MyForm.submit();
    return true;
  }
  return false;
}

function closePage() {
  MyForm.action = "close.php";
  MyForm.method = "POST";
  MyForm.submit();
  return true;
}

Hope it helps you out...

Regards,
Niral Soni[/QUOTE]

I need some clarification on the above code

can I use as below in the above function

PHP Code:
MyForm.action = "save.php?xyz=<?echo $xyz;?>";
nani_nisha06 is offline   Reply With Quote
Old 02-04-2013, 12:51 PM   PM User | #4
nani_nisha06
Regular Coder

 
Join Date: Oct 2012
Location: mother land --india
Posts: 159
Thanks: 37
Thanked 2 Times in 2 Posts
nani_nisha06 is an unknown quantity at this point
Quote:
Originally Posted by niralsoni View Post
html will look something like this (calling two different JavaScript functions on two buttons) -
Code:
<form name="MyForm"> 
.....
.....
<input type="button" value="Save" onclick="return saveData()">
<input type="button" value="Close" onclick="return closePage()">
.....
.....
</form>
Then in the JavaScript function, set the action attribute of form as -
Code:
function saveData() {
  // logic for validating form data etc.
  // if all successful
  {
    MyForm.action = "save.php";
    MyForm.method = "POST";
    MyForm.submit();
    return true;
  }
  return false;
}

function closePage() {
  MyForm.action = "close.php";
  MyForm.method = "POST";
  MyForm.submit();
  return true;
}
Hope it helps you out...

Regards,
Niral Soni
This one worked......
nani_nisha06 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:43 AM.


Advertisement
Log in to turn off these ads.