473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to use multiple button in single php form with validation?

Hello everyone..


I am trying to use multiple buttons in single php form with validations with given below functions:
But i am facing problem when i click on submit button after checking all validations,its not submitted.

Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="button" value="Submit" onClick="return submit_form();buttonClicked(1);">
  2. <input type="button" name="button" id="button" value="Preview" onClick="buttonClicked(2)">
  3. <input type="button" name="button" id="button" value="Print" onClick="buttonClicked(3)">
  4.  
  5. <script type="text/javascript">
  6. function buttonClicked(which){
  7. if (which == 1 ) {   
  8. document.f1.action = 'ebooking_email.php';
  9. }
  10.   else if(which==2) { 
  11.       document.f1.target="_blank";
  12.          document.f1.action = 'preview_booking.php'
  13.     }
  14.      else if(which==3) { 
  15.         document.f1.target="_blank";
  16.          document.f1.action = 'ebooking_print.php'
  17.     }
  18.      document.f1.submit(); 
  19. }
  20. </script>
Sep 30 '10 #1
2 2397
dlite922
1,584 Expert 1GB
put alert() calls in each of your if functions to see if any of them get called.

I don't think there's such a thing as document.f1

This is a Javascript issue and not a PHP problem. You have better chances of getting a good quick answer if you posted this in the JavaScript forum.

Try using: document.forms[0].*


Dan
Sep 30 '10 #2
oranoos3000
107 100+
hello
f1 is the id of your form?
you can give name attribute to your form and use

document.forms["f1"].submit();
that f1 is value of the name attribute form
Sep 30 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
2
by: Nick Bell | last post by:
I have a general form validation question. I know very little about javascript, a little more about PHP. Using yav (http://yav.sourceforge.net): <form method="POST" name=edit onsubmit="return...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
1
by: iMedia User | last post by:
I have a site where I want to use the Web form validators in two separate forms on a single page. One form allows existing users to log in while the second one allows new users to register. The...
4
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
5
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The...
2
by: munkee | last post by:
Hi all, Basically I have been using form validation incorrectly. Partly because of laziness which I now feel is going to really bite me back if I dont get it sorted. On all of my forms I have a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.