473,375 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,375 software developers and data experts.

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(myvalue) {
//works
document.forms[0].testProperty.value = myvalue;
alert('document.forms[0].testProperty.value='+document.forms[0].testProperty.value);
//doesn't work
//(javascript error:
//document.forms[0].dotted.prop is null or not an object)
document.forms[0].dotted.prop.value = myvalue;
alert('document.forms[0].dotted.prop.value='+document.forms[0].testProperty.value);
}
//-->

<form>
<input type="hidden" name="testProperty" value="">
<input type="hidden" name="dotted.prop" value="">
</form>

Any comments are appreciated.

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


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.value = myvalue;


How to access properties with illegal names:
<URL:http://jibbering.com/faq/#FAQ4_25>
I.e.,
document.forms[0].elements["dotted.prop"].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.no...
<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(myvalue) {
//works
document.forms[0].testProperty.value = myvalue;
alert('document.forms[0].testProperty.value='+document.forms[0].testProperty.value);
//doesn't work
//(javascript error:
//document.forms[0].dotted.prop is null or not an object)
document.forms[0].dotted.prop.value = myvalue;
alert('document.forms[0].dotted.prop.value='+document.forms[0].testProperty.value);
}
//-->


Try:

(document.forms[0])["dotted.prop"].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
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"...
6
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...
3
by: Sharon | last post by:
Hi guys , What is the apache struts equivalent in the .net world ? (if any ..) Thank you Sharon
136
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...
4
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>...
1
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 ...
1
by: eunever32 | last post by:
Hi I have a struts (1.1) form <html:form <html:text <html:text ...
0
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.