473,385 Members | 1,730 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,385 software developers and data experts.

How can I submit a form with an anchor tag

JnrJnr
88
This might seem like a Javascript question but I can already submit the form with an anchor tag via javascript. Thats fine.
My actual question is how does PHP incorporate itself in the form post of an anchor tag?
Usually if you use a submit button you would use the $Post or $Get array with an isset() method to tell the form what to do or post. How do I tell the form what to do after an anchor tag post?
Anchor tag post:
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:document.MainForm.submit()" onclick="return validate()" name="submit"><img src="buttons/Submit.png" border=0 alt="Submit"></a>
help would really be appreciated
Sep 14 '11 #1
5 13985
Dormilich
8,658 Expert Mod 8TB
the anchor tag does not play a role here as it is simply used to trigger the form to submit (via JavaScript). what values to send to the server is (like in the case of a submit button) solely handled by the browser.

PHP doesn’t even know that the form was submitted through an anchor tag. it gets regular form data. PHP can’t even differentiate between a form submission and AJAX.

though in your case, I wouldn’t even bother with an anchor. either put the handlers on the image or use a <button> element.
Sep 14 '11 #2
JnrJnr
88
thanx for the reply. I used an image before to submit but then tried anchor tags because the image tag onclick event does not seem to fire.

This probably is crazy but what Im trying to do is create two submit buttons on one form.
Both buttons use javascript for mouseovers etc.
I need javascript to do some validation first and also to tell me which button was clicked/submitted so that I can use the appropriate isset($Post_) method. Is it normal to use two submit buttons?
Any suggestions?
Sep 14 '11 #3
Dormilich
8,658 Expert Mod 8TB
that depends on what you consider normal. if you have a reason to use different buttons, why not? the disadvantage is, that some versions of IE do not submit the name of the submit button (i.e. you don’t know which button was pressed).
Sep 15 '11 #4
JnrJnr
88
Ok fine. Let me get back to topic. Could you give me a code example of how form data is sent to the server via a submit action using an anchor tag please?

Take a look here: http://webdeveloper.internet.com/for...d.php?t=126792
(this is exactly what I want to do except that onclick event does not work with HTML input type image)
Sep 15 '11 #5
Dormilich
8,658 Expert Mod 8TB
provided, JavaScript is enabled:
Expand|Select|Wrap|Line Numbers
  1. <a id="submitter">Submit</a>
Expand|Select|Wrap|Line Numbers
  1. #submitter {
  2.     cursor: pointer;
  3. }
Expand|Select|Wrap|Line Numbers
  1. function submit_form()
  2. {
  3.     document.myForm.submit();
  4. }
  5. document.getElementById("submitter").addEventListener("click", submit_form, false);
Sep 15 '11 #6

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

Similar topics

2
by: vishal | last post by:
hello friends i have one php script which generates html page containing form. what i want is submit this form using php script. pls give me some idea that how can i submit form using php...
3
by: Mark Michel | last post by:
Hi. I have made an html form which I would like to send by e-mail. When the recipient receives the e-mail form, I would like them to be able to fill it out and click the Submit button which will...
2
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
2
by: Matt | last post by:
I tried to figure out how many approaches to submit form data. Here's my attempts. Please advise. Thanks!! 1) html submit button, most commonly used. <form name="formName" action="url"...
3
by: Matt | last post by:
When people say submit the form data, does it mean the form data are submitted to web browser using either HTTP GET or POST method, and then it will redirect to another page. For example, this...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
1
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
1
by: sam | last post by:
Hi All, I have a form with 4 checkboxes and 4 text boxes and one submit button. The form should work such a way when I select a particular checkbox and give a url in text box, the form should...
1
by: metalforever | last post by:
How do you redirect a form after submit(form sends email) ? This is pretty urgent for me. I have included the code in a pastebin. http://pastebin.org/249014 process_form sends the email. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.