473,732 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Elements with same name in different forms

6 New Member
Hi guys


I have the following situation: In mypage1.jsp I have 4 forms, each with a different name (and id). But on these forms, there are some fields that have the same name, for example

mypage1.jsp:

Expand|Select|Wrap|Line Numbers
  1. <form action="" name="form1" id="form1" method="POST" >
  2. <input type="hidden" name="myValFld" value=""/> 
  3. .....
  4. </form>
  5.  
  6. <form action="" name="form2" id="form2" method="POST" >
  7. <input type="hidden" name="myValFld" value=""/> 
  8. .....
  9. </form>

and I have some images that can be clicked inside each of these forms, and they call a javascript to set the hidden field and submit the form:

Expand|Select|Wrap|Line Numbers
  1. function goAndSub(Form,URL,Action){
  2.  
  3.  
  4.     document.forms[Form].elements['myValFld'].value = Action;
  5.     document.getElementById(Form).action = URL;
  6.     document.getElementById(Form).submit();
  7.  
  8. }

Now the problem is , even though both the forms have exactly the same way of calling the javascript method, one of them successeds and the other gives error message:

document.forms[...].elements.myVal Fld is null or not an object.

Could you please advise?

Many thanks
Vajra
Dec 14 '07 #1
2 1909
acoder
16,027 Recognized Expert Moderator MVP
Try renaming the Action parameter to Val or something.

Give an example of a function call that fails.
Dec 14 '07 #2
mrhoo
428 Contributor
You can use document.getEle mentsByName('my ValFld')[0] and
document.getEle mentsByName('my ValFld')[1]- the node list index will be the same as the forms index, if you have the same name in every form.
Dec 14 '07 #3

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

Similar topics

4
6777
by: Doug Estep | last post by:
Below is a sample of my XML… <MetaData> <Table name="mytable"> <PrimaryKey name="pk"><Column name="mycolumn"/></PrimaryKey> </Table> </MetaData> <Sequencer> <Table name="mytable">
2
12872
by: juglesh | last post by:
hi, all, thanks for reading. i have a form in which i want drop down boxes to dynamically change some hidden fields: http://cynthialoganjewelry.com/test4.htm <form name=test method="post" > Pearl Color: <select name="product1">
11
2255
by: Jon Hoowes | last post by:
Hi, I have inherited some code that has some form elements (radio buttons) that are called "1", "2" etc. for example: <input name="2" type="radio" value="45"> <input name="2" type="radio" value="46">
22
3333
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements: <form name="myform"> <input name="myinput" /> </form> 1. var input = document.forms.myform.myinput;//from nn3+ 2. var input = document.forms.myinput;//from nn3+
13
371
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a base class for the worker class, and made up some functions/delegates to handle the invoke stuff for the UI and that was fine for a prototype. I rewrote this chunk, broke things out into different classes - but the threading is still the same - and...
4
1655
by: Leszek | last post by:
Hi. <div id="id1"> <select name="name"> //options </select> </div> <div id="id2"> <select name="name">
4
3206
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively search a parent element(in my case a <table>) and search for elements of a certain type (<input>, <textarea>, etc) and perform operations on them. I've done some initial googling and found PLENTY of samples of disabling all form items, but I...
4
2139
by: Beagle804 | last post by:
OK. I'm very new to Javascript and what I've learned so far has been find snippets of code on the web and using them in my php programs. I put together an application that allows a Reset button to clear radio inputs in a portion of the page. And another button which will also set the values of these same radio's to a certain value. The form is for evaluating a speaker at a conference. I programmed everything using Firefox for testing and my...
14
1804
by: jmDesktop | last post by:
I have a food menu. Each area, like beverages, grill, etc. have items under them, Coke, Tea, Coffee would be under beverages for example. I want to add a new drink to beverages. In my database I have an "area" like above, Bevs, Grill, Chicken... In my menu items I have an ID from the area so, table areas id 1 areaname beverages id 2 areaname grill
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
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.