473,503 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using hyperllinks to submit a form

I know that <a href="javascript:document.formname.submit();"> works for
this, but can you use a hyperlink to submit a form WITHOUT assigning the
form tags name attribute a value. The site I am currently working on is
supposed to be HTML 4 (w3c) complient, but according to the HTML validator
the name attribute has been depreciated and should no longer be used. I'm
not saying I agree with this, just that I have little choice in the matter.
Thoughts?

Alex
Jul 20 '05 #1
2 5311
David Dorward wrote:
Alexander Ross wrote:
I know that <a href="javascript:document.formname.submit();"> works


For some definitions of "work" - http://tom.me.uk/scripting/submit.asp
for
this, but can you use a hyperlink to submit a form WITHOUT assigning the
form tags name attribute a value. The site I am currently working on is
supposed to be HTML 4 (w3c) complient, but according to the HTML validator
the name attribute has been depreciated and should no longer be used.


You can access it via the id attribute,
document.getElementById('id_of_form').submit() - but removing the
dependancy on JavaScript would be the better option (see the above URL).


The default document object in most browsers contain a list of form objects on
the page as a 0-indexed array. Using document.getElementById() is unnecessary.

<a href="#" onclick="document.forms[0].submit();return false;">Submit</a> will
work just fine.

Although I agree, remove the dependancy on the link entirely and use a normal
<input type="submit" ...> with CSS to make it look like a link. Sure, in older
browsers it'll be a big ugly button, but in newer browsers it'll look like a
link, and in all browsers it should submit the form, regardless of JavaScript
support.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2
"Alexander Ross" <al******@bleen.net> writes:
I know that <a href="javascript:document.formname.submit();"> works for
this,
"this" == subject. (Putting vital parts of a message in the subject is
highly distracting).

Using the javascript: pseudo protocol is a bad idea. You should at least
use

<a href="nonJS.html"
onclick="document.forms['formname'].submit()";return false;">

where "nonJS.html" expains why you can't build a functional page
without javascrtip.

A better solution is to use asubmit button inside the form.
but can you use a hyperlink to submit a form WITHOUT assigning the
form tags name attribute a value. The site I am currently working on is
supposed to be HTML 4 (w3c) complient, but according to the HTML validator
the name attribute has been depreciated and should no longer be used.


.... however, one should use the "id" attribute instead.

If that fails, you can index "document.forms" with integers too,
so the first form is "document.forms[0]".

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3987
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...
7
20896
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
4
2319
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
4
7543
by: Peloux | last post by:
Hi, I have written some htc in order to validate data in a form. most of htc are attached on 'onblur' event. Now, we would like to use the Enter Key to sublit form, so we use the following...
8
5715
by: Adam | last post by:
Hey, I'm using JS to submit a form with image submit buttons, using the following code... (Page is here... http://www.cards2do.co.uk/addcard.php?card_id=292 ) ...
4
20989
by: devine | last post by:
Hi All, I am VERY new to Javascript. I have been provided with some code, which will enable me to hide/show a text area and change a submit button dependant on a check box. <!DOCTYPE html...
23
14450
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
19
247991
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
2751
by: Arpit Nagar | last post by:
Hi... I am creating a dummy project for collage. Here I had choosen my project as Jewelleryshoping. Now the scenerio is like that thier are jewellry item which I had display in table format with...
0
7072
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
7271
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,...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.