473,569 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.forms[0] and Struts (tags)

Hi,

I have a problem to access a hidden field by javascript. The name of
the field has a dot in it. That's the problem. But I need that dot
because it is a "Stuts Property".
I'm using IE 6. This is my code:

<!--
function changeValue(myv alue) {
//works
document.forms[0].testProperty.v alue = myvalue;
alert('document .forms[0].testProperty.v alue='+document .forms[0].testProperty.v alue);
//doesn't work
//(javascript error:
//document.forms[0].dotted.prop is null or not an object)
document.forms[0].dotted.prop.va lue = myvalue;
alert('document .forms[0].dotted.prop.va lue='+document. forms[0].testProperty.v alue);
}
//-->

<form>
<input type="hidden" name="testPrope rty" value="">
<input type="hidden" name="dotted.pr op" value="">
</form>

Any comments are appreciated.

Cheers,
Jan.
Jul 20 '05 #1
4 27532
jm*****@bigfoot .de (Jan-Friedrich Mutter) writes:
document.forms[0].dotted.prop.va lue = myvalue;
alert('document .forms[0].dotted.prop.va lue='+document. forms[0].testProperty.v alue);


Use getElementById( 'dotted.prop')
Jul 20 '05 #2
jm*****@bigfoot .de (Jan-Friedrich Mutter) writes:
I have a problem to access a hidden field by javascript. The name of
the field has a dot in it. That's the problem. But I need that dot
because it is a "Stuts Property".
It is illegal HTML, so you should check again whether it is *really*
necessary.
document.forms[0].dotted.prop.va lue = myvalue;


How to access properties with illegal names:
<URL:http://jibbering.com/faq/#FAQ4_25>
I.e.,
document.forms[0].elements["dotted.pro p"].value

/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
"Tor Iver Wilhelmsen" <to************ *****@broadpark .no> wrote in
message news:ul******** ***@broadpark.n o...
<snip>
Use getElementById( 'dotted.prop')


Do not use getElementById to access form elements with JavaScript. Use
the W3C HTML DOM level 2 specified document.forms collection to access
the form and access the element as either a named or indexed property of
either the form or the form's elements collection:-

document.forms[nameOrIndex].elements[nameOrIndex];

- complies with the latest W3C specification and is back-compatible with
_every_ JavaScript capable browser currently in use.

Richard.
Jul 20 '05 #4
Jan-Friedrich Mutter wrote:
I have a problem to access a hidden field by javascript. The name of
the field has a dot in it. That's the problem. But I need that dot
because it is a "Stuts Property".
In general, it's best not to post JavaScript questions to
comp.lang.java. * groups. Java and JavaScript are not the same.
Followups are set.
I'm using IE 6. This is my code:

<!--
function changeValue(myv alue) {
//works
document.forms[0].testProperty.v alue = myvalue;
alert('document .forms[0].testProperty.v alue='+document .forms[0].testProperty.v alue);
//doesn't work
//(javascript error:
//document.forms[0].dotted.prop is null or not an object)
document.forms[0].dotted.prop.va lue = myvalue;
alert('document .forms[0].dotted.prop.va lue='+document. forms[0].testProperty.v alue);
}
//-->


Try:

(document.forms[0])["dotted.pro p"].value = myvalue;

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 20 '05 #5

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

Similar topics

9
6493
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I...
6
4491
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below...
3
375
by: Sharon | last post by:
Hi guys , What is the apache struts equivalent in the .net world ? (if any ..) Thank you Sharon
136
9250
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to...
4
1969
by: SB | last post by:
Hi I'm trying to get forms-based authentication to authenticate different users for differet pages, like this: <configuration> <location path="Member" allowOverride="true"> <system.web> <authorization> <!-- allow tags must be first --> <allow users="Admin"/>
1
2784
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader delegate: false repositories:
1
2603
by: eunever32 | last post by:
Hi I have a struts (1.1) form <html:form <html:text <html:text ...
0
1000
by: anonymous | last post by:
hello im trying to generate a page (jsp) that contains a struts form <html:.... using a xsl and xml files and (transform the xml with the xsl on server side) but the problem that when i type a struts tag <html:text .. . . in the xsl file, the xsl does NOT accept the tag, what should i do to enable struts tags in the xsl and generate the form? ...
0
2122
by: deepcw | last post by:
I was trying form design using struts and wml tags by struts-wml.tld, but I also need to take handle event in script like text on change or select box onchange events. I didn't find any way to do this. Can't I do scripting with struts wml elements or is there any other way? Thanks
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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
8119
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...
1
7668
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...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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
5509
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
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
936
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.