473,586 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing hidden objects in a form

Can anyone tell me the best way to access a hidden object in a form? I
could use a hard-coded index to the elements of the form, but it's too
easy to add something before the hidden object and mess up the
indexing.

For example:

The form has a tagid of "myForm"
The hidden object has a tagId of "myHiddenOb j"

I can get the form elements by using
var formElements = document.getEle mentById('myFor m').elements

But there doesn't seem to be any way to do this:
document.getEle mentById('myHid denObj')

Assuming I have the elements as obtained above, none of these have
worked for me either:

formElements['myHiddenObj']
formElements["myHiddenOb j"]
formElements.my HiddenObj

Anyone have an idea?
Jul 23 '05 #1
5 2436
cr************@ vykor.com (Craig Anderson) wrote in message news:<ea******* *************** ***@posting.goo gle.com>...
Can anyone tell me the best way to access a hidden object in a form? I
could use a hard-coded index to the elements of the form, but it's too
easy to add something before the hidden object and mess up the
indexing.

For example:

The form has a tagid of "myForm"
The hidden object has a tagId of "myHiddenOb j"

I can get the form elements by using
var formElements = document.getEle mentById('myFor m').elements

But there doesn't seem to be any way to do this:
document.getEle mentById('myHid denObj')

Assuming I have the elements as obtained above, none of these have
worked for me either:

formElements['myHiddenObj']
formElements["myHiddenOb j"]
formElements.my HiddenObj

Anyone have an idea?


document.getEle mentById is for accessing HTML elements with id's. If
there is no ID, you will not see them. Unfortunately ID access is
slow as the data is not efficiently indexed. Instead access through
document.forms. ..

Use form document.forms['formname'] and for the elements, I prefer to
use the shortcut to the elements
document.forms['formname']['formelemname']. This syntax works smoothly
in Mozilla and IE.

I generally assign the form to a global variable `oF` since I commonly
access it more that once in my code
(window.oF=docu ment.forms['formname']). I Then reference with the
shortcut accessor oF['myHiddenObj'] to access form elements in. This
syntax is the the most compact and should be efficient. I have not
tested this syntax outside of Moz and IE though. For standards
compliant access, use document.forms['formname'].elements['elemname'].

There is one known bug in IE with the shortcut syntax above whereas if
the form element names start with a number ( which it should not
anyway ) IE cannot find them.

For additional info check out javascript FAQ -
http://www.jibbering.com/faq/faq_not....html#faComMis

JsD
Jul 23 '05 #2
On 1 Jul 2004 17:03:44 -0700, Craig Anderson <cr************ @vykor.com> wrote:
Assuming I have the elements as obtained above, none of these have
worked for me either:

formElements['myHiddenObj']
formElements["myHiddenOb j"]
formElements.my HiddenObj

Anyone have an idea?


document.forms['nameofform']['myHiddenObj'] should work *IF* the script fragment
comes physically after the form element on the page.

-rs-
Jul 23 '05 #3
Ralph Snart wrote:
On 1 Jul 2004 17:03:44 -0700, Craig Anderson <cr************ @vykor.com> wrote:
Please do not write attribution novels. The information you have
included is already contained in the headers of the involved postings.
Only the poster's name is required to see who wrote what of the quoted
text. <http://www.netmeister. org/news/learn2quote.htm l>
[...]
document.forms['nameofform']['myHiddenObj'] should work *IF* the
script fragment comes physically after the form element on the page.


When a DOM object becomes available depends on the DOM, on the UA.
Furthermore, your referencing is neither standards compliant nor
backwards compatible. The following is both:

document.forms['nameofform'].elements['myHiddenObj']

However, in most cases relative referencing, such as starting
from the (parent) form element with `this' or `this.form' in
an event handler, will suffice.
PointedEars
Jul 23 '05 #4
JRS: In article <40************ **@PointedEars. de>, seen in
news:comp.lang. javascript, Thomas 'PointedEars' Lahn
<Po*********@nu rfuerspam.de> posted at Sat, 10 Jul 2004 02:30:11 :
Ralph Snart wrote:
On 1 Jul 2004 17:03:44 -0700, Craig Anderson <cr************ @vykor.com>wrote:

Please do not write attribution novels. The information you have
included is already contained in the headers of the involved postings.
Only the poster's name is required to see who wrote what of the quoted
text. <http://www.netmeister. org/news/learn2quote.htm l>

The current Internet draft REQUIRES more than that, and is quite
encouraging to those who wish to provide more than is strictly called
for.
http://www.ietf.org/internet-drafts/...-useage-00.txt

Please stop trying to be a petty dictator; Mussolini at least did (or so
I have heard) something towards getting the trains to run on time, and
dictatorial mis-rule is nowadays considered passé.

Aside : ISTM that the "stringy" LZ is a little slower than the numeric
one; unless others find otherwise, it's probably best used only
for bases other than 10.

TL wrote elsewhere :The word "I" is always capitalized in English.


Unfamiliar with e e cummings, then?

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #5
Dr John Stockton wrote:
JRS: In article <40************ **@PointedEars. de>, seen in
news:comp.lang. javascript, Thomas 'PointedEars' Lahn
<Po*********@nu rfuerspam.de> posted at Sat, 10 Jul 2004 02:30:11 :
Ralph Snart wrote:
On 1 Jul 2004 17:03:44 -0700, Craig Anderson <cr************ @vykor.com>

wrote:

Please do not write attribution novels. The information you have
included is already contained in the headers of the involved postings.
Only the poster's name is required to see who wrote what of the quoted
text. <http://www.netmeister. org/news/learn2quote.htm l>


The current Internet draft REQUIRES more than that, and is quite
encouraging to those who wish to provide more than is strictly called
for.
http://www.ietf.org/internet-drafts/...-useage-00.txt

Please stop trying to be a petty dictator; Mussolini at least did (or so
I have heard) something towards getting the trains to run on time, and
dictatorial mis-rule is nowadays considered passé.


What I find most annoying is that he claims such "attributio n novels" waste
bandwidth and make it harder to follow the flow of the usenet post, but Thomas'
responses to such "novels" are longer (thereby wasting _more_ bandwidth) and
disrupt the flow of the post even further.

Much like banner ads on Web sites, I mentally "tune out" the noise introduced by
quoted material on usenet, but his responses to the noise appear at first to
contain meaningful information. It is only after I have read most of his response
that I realize it is nothing more then additional noise.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #6

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

Similar topics

1
1519
by: Esben Rune Hansen | last post by:
Hi I am working on a PHP-script and need javascript to set the value of a hidden field in a form. This field happens to be an entry in an array data according to my example. How can I do this? Below is listet two PHP-pages: one that doesn't work (to my dismay), and another that does work, but do not use an array entry in the hidden field....
18
2076
by: Choxio | last post by:
Using ASP you can access posted form elements. Is it possible to access them from JavaScript? myHTML.htm <form action=myASP.asp> <input type=hidden id=f1 value=val1> <input type=hidden id=f2 value=val2> <input type=submit value="Choose Me"> </form>
1
5767
by: Andrew Wrigley | last post by:
Hi Should a hidden form become visible when all other forms are closed? This is what happens, and to ensure that it is always hidden, I have to set the on got focus event handler of the form to Me.Visible = False to ensure that it is always hidden, no matter what.
3
1971
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated before the page is changed? I want to say that because the values are changed but the page is never reloaded after the change, that these changes do not...
1
3116
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such...
1
3833
by: j.eckles | last post by:
I'm trying to determine if there is a way in VBScript, perhaps via ADO or DAO, to access what I'll term MS Access "object groups". What I mean by "object groups" are the folders that you see under the "Groups" pane on the left hand side of the Access 2003 application, just below the "Objects" pane. There's always one default Group called...
19
10532
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' ); It is working fine in IE. But in Mozilla Firefox , null value is returned.Is there any way to use hidden variables compatible to browsers......?
0
12065
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
1
1465
by: Vinodsrvk | last post by:
I am accessing a string from the previous page's hidden text. While I am reading the string the only last character of the string is getting truncated. When I tried viewing the string in the previous page itself I could see the complete string. I have formed the string in the main page using java code as bellow...
0
7839
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...
0
8200
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. ...
0
8338
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...
0
6610
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...
1
5710
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...
0
5390
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...
0
3836
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.