SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Multiple forms on one page
-
Jan 10, 2007, 09:40 #1
- Join Date
- May 2005
- Location
- S.W. France
- Posts
- 2,496
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Multiple forms on one page
Hi
I have an html page with multiple forms, I wish to use javascript to check the value of a dropbox (name=os0) and submit if the value is valid.
If I name the form 'myform' I can use this code
Code:<A href="javascript: document.myform.submit();" onclick="if(document.myform.os0.value==56){alert('txt');return false};">Acheter</A>
Is there a way of checking and submitting the forms without explicity naming them, I thought I could do this using something like
Code:<A href="javascript: document.this.form.submit();" onclick="if(document.this.form.os0.value==56){alert('txt');return false};">Acheter</A>
Any help appreciated
TerryA Little Knowledge Is A Very Dangerous Thing.......
That Makes Me A Lethal Weapon !!!!!!!!
Contract PHP Programming
-
Jan 10, 2007, 10:39 #2
- Join Date
- Nov 2004
- Location
- Nelson BC
- Posts
- 2,310
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can refer to the parent form of a form element using the "form" property, for example:
<input type="button" onclick="this.form.submit();" value="click me" />
But if you are using the <a> tag, which is not a form element, you'll need a way to identify which form you want to work with, either by use of a name attribute or an id, or by using the form index (0,1,2 etc).
-
Jan 10, 2007, 13:47 #3
- Join Date
- May 2005
- Location
- S.W. France
- Posts
- 2,496
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Arhh, I see, i'd foolishly assumed that because the <a> tag was inside the <form> </form> tags it would refer to that form above the others, I'll have another think, perhaps I'll change the <a> tag for an image and use input type='image' instead
Thanks for your input
TerryA Little Knowledge Is A Very Dangerous Thing.......
That Makes Me A Lethal Weapon !!!!!!!!
Contract PHP Programming
Bookmarks