473,614 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XHTML 1.1 vs name="abc"

I had a page that works when setup like this:

===
<form name="frmCalc" action="">

<script type="text/javascript">

function btnCalc_onclick (abc) {
return "got here with " + abc;
}

</script>

<p>
<textarea name="tareaResu lts" rows="2" cols="20"></textarea>
</p>
<p>
<input type="button" value="Calculat e" name="btnCalc"
onclick="docume nt.frmCalc.tare aResults.value= btnCalc_onclick ('ghijk');" />
</p>

</form>
===

In trying to upgrade and validate it as XHTML 1.1, the name attribute
invariable seems to make the validator gag.

I can validate it by changing to:

===
<form id="frmCalc" action="">
....
<textarea id="tareaResult s" rows="2" cols="20"></textarea>
....
<input type="button" value="Calculat e" id="btnCalc"
onclick="docume nt.frmCalc.tare aResults.value= btnCalc_onclick ('ghijk');" />
....
===

But now the script gags when executed: "document.frmCa lc.tareaResults is
null or not an object."

Somewhere I read thet getElementById was the "magic bullet. So I tried
constructions like this with no joy:

===
....
<input type="button" value="Calculat e" id="btnCalc"
onclick="docume nt.getElementBy Id('frmCalc').g etElementById(' tareaResults'). value=btnCalc_o nclick('ghijk') ;"
....
===

I've spent lots of the day trying to google a solution with no joy.

My Qs:

1) what's a construction for the onclick attribute that will work with the
id="frmCalc" and id="tareaResult s"???

2) what defines the rules for interpreting the contents of the onclick
attribute? javascript/ecmascript? XHTML1.1? In other words, where are the
rules defined that tell me why what I'm doing isn't working and what to do
instead?

Thanks in advance!
Feb 11 '07 #1
6 2295
On Feb 11, 2:19 am, "Dick Watson" <littlegreenge. ..@mind-enufalready-
spring.comwrote :
<input type="button" value="Calculat e" id="btnCalc"
onclick="docume nt.getElementBy Id('frmCalc').g etElementById(' tareaResults'). value=btnCalc_o nclick('ghijk') ;"
At first sight, you've very close. getElementById' s scope is the whole
document, just say: document.getEle mentById('tarea Results').value =blah

Feb 11 '07 #2
Gee that was easy. Where were you at 11:30 this morning? Thanks!

BTW, the second question still stands--what defines the syntax, etc., of the
parameter in onclick="parame ter"? Is it javascript? Is it XHTML? DOM?

"Emmanuel" <sa******@gmail .comwrote in message
news:11******** *************@v 45g2000cwv.goog legroups.com...
On Feb 11, 2:19 am, "Dick Watson" <littlegreenge. ..@mind-enufalready-
spring.comwrote :
><input type="button" value="Calculat e" id="btnCalc"
onclick="docum ent.getElementB yId('frmCalc'). getElementById( 'tareaResults') .value=btnCalc_ onclick('ghijk' );"

At first sight, you've very close. getElementById' s scope is the whole
document, just say: document.getEle mentById('tarea Results').value =blah

Feb 11 '07 #3
On Feb 11, 11:19 am, "Dick Watson" <littlegreenge. ..@mind-enufalready-
spring.comwrote :
I had a page that works when setup like this:

===
<form name="frmCalc" action="">

<script type="text/javascript">

function btnCalc_onclick (abc) {
return "got here with " + abc;

}

</script>

<p>
<textarea name="tareaResu lts" rows="2" cols="20"></textarea>
</p>
<p>
<input type="button" value="Calculat e" name="btnCalc"
onclick="docume nt.frmCalc.tare aResults.value= btnCalc_onclick ('ghijk');" />
The best way to get a reference from the button to the form is to use
"this.form" , but that doesn't really answer your question. :-)

Another answer is that using XHTML on the web, served as XHMTL, will
cause you never-ending headaches for zero benefit. Given that the
vast majority of users out there are using a browser that doesn't know
what XML is, you have to serve HTML to those users anyway.

You might decide to use content negotiation and serve XHTML to some
browsers and HTML to others, but what's the point? Just use HTML 4.01
strict and your HTML will work from now till doomsday in every decent
browser in use (which is pretty much any browser released in the last
10 years).

Script and DOM support is another matter...

</p>

</form>
===

In trying to upgrade and validate it as XHTML 1.1, the name attribute
invariable seems to make the validator gag.
XHTML 1.1 removes support for deprecated elements and attributes -
support for the name attribute for forms has been removed, as you
discovered.
>
I can validate it by changing to:

===
<form id="frmCalc" action="">
...
<textarea id="tareaResult s" rows="2" cols="20"></textarea>
...
<input type="button" value="Calculat e" id="btnCalc"
onclick="docume nt.frmCalc.tare aResults.value= btnCalc_onclick ('ghijk');" />
...
===

But now the script gags when executed: "document.frmCa lc.tareaResults is
null or not an object."

Somewhere I read thet getElementById was the "magic bullet. So I tried
constructions like this with no joy:
For the form element, yes, but not for form controls. They *must*
have a name or they won't be submitted with the form.
>
===
...
<input type="button" value="Calculat e" id="btnCalc"
onclick="docume nt.getElementBy Id('frmCalc').g etElementById(' tareaResults'). value=btnCalc_o nclick('ghijk') ;"
getElementById is a method of the document, not an element. If you
want to get references that way just go directly to the element you
want:

document.getEle mentById('tarea Results')...
or to go via the form:

document.getEle mentById('frmCa lc').tareaResul ts.value ...

or:
document.getEle mentById('frmCa lc').elements['tareaResults'].value ...

But using IDs on form controls can get confusing, I prefer to just use
names as they are needed anyway, why add an ID unless there's a
compelling need for it?

...
===

I've spent lots of the day trying to google a solution with no joy.

My Qs:

1) what's a construction for the onclick attribute that will work with the
id="frmCalc" and id="tareaResult s"???
Use an ID for the form. You can give form controls both name and ID
attributes, but that gets messy with things like radio buttons, so
just use name unless you really want an ID.
>
2) what defines the rules for interpreting the contents of the onclick
attribute? javascript/ecmascript? XHTML1.1?
The HTML 4 specifiction in conjunction with the XHTML 1.1
specification, plus the various DOM Level 2 specifications (Core,
HTML, Event, etc.) and the DOM Level 3 specifications.
In other words, where are the
rules defined that tell me why what I'm doing isn't working and what to do
instead?
<news: comp.lang.javas cript >

<news: comp.infosystem s.www.authoring.html >
<URL: http://groups.google.com.au/group/
comp.infosystem s.www.authoring.html/topics?lnk=li&hl=en >

<news: comp.infosystem s.www.authoring.stylesheets >
<URL: http://groups.google.com.au/group/
comp.infosystem s.www.authoring.stylesheets/topics?lnk=li&hl=en >

--
Rob

Feb 11 '07 #4
RobG wrote:
<snip>
document.getEle mentById('frmCa lc').tareaResul ts.value ...
Referencing named or IDed form controls as named members of a FORM
element is non-standard and effectively relying upon a 'shortcut' that
has been observed as consistently available in HTML DOMs but is not
necessarily available in XHTML DOMs. If the intention here is to use
XHTML, as opposed to just giving the mark-up author the illusion of using
XHTML, then this would be a bad alternative.
or:
document.getEle mentById('frmCa lc').elements['tareaResults'].value
<snip>

or:-

document.forms['frmCalc'].elemnts['tareaResults'].value

- as the W3C HTML DOM specification requires that IDed FORM elements may
be referenced as named members of the - document.forms - collection.

Richard.

Feb 11 '07 #5
Buy, that's a lot of places to define one simple attribute. No wonder I
couldn't find a simple answer. It would certainly be easier to develop for
the web if the standards lawyers would find some other problem to work on
for a while...

Thanks for your informative post!

"RobG" <rg***@iinet.ne t.auwrote in message
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
>2) what defines the rules for interpreting the contents of the onclick
attribute? javascript/ecmascript? XHTML1.1?

The HTML 4 specifiction in conjunction with the XHTML 1.1
specification, plus the various DOM Level 2 specifications (Core,
HTML, Event, etc.) and the DOM Level 3 specifications.
>In other words, where are the
rules defined that tell me why what I'm doing isn't working and what to
do
instead?

<news: comp.lang.javas cript >

<news: comp.infosystem s.www.authoring.html >
<URL: http://groups.google.com.au/group/
comp.infosystem s.www.authoring.html/topics?lnk=li&hl=en >

<news: comp.infosystem s.www.authoring.stylesheets >
<URL: http://groups.google.com.au/group/
comp.infosystem s.www.authoring.stylesheets/topics?lnk=li&hl=en >

Feb 11 '07 #6
On Feb 11, 10:22 pm, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
RobG wrote:

<snip>
document.getEle mentById('frmCa lc').tareaResul ts.value ...

Referencing named or IDed form controls as named members of a FORM
element is non-standard and effectively relying upon a 'shortcut' that
has been observed as consistently available in HTML DOMs but is not
necessarily available in XHTML DOMs. If the intention here is to use
XHTML, as opposed to just giving the mark-up author the illusion of using
XHTML, then this would be a bad alternative.
Fair enough, I was relying upon (probably insufficient) testing.

[...]
or:-

document.forms['frmCalc'].elemnts['tareaResults'].value

- as the W3C HTML DOM specification requires that IDed FORM elements may
be referenced as named members of the - document.forms - collection.
In compliant browsers, maybe (typo excepted) - but unfortunately at
least one reasonably common one (Safari) appears not to be and it
fails for XHTML documents, although it works fine for HTML documents.
Perhaps I should have mentioned that.
--
Rob

Feb 12 '07 #7

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

Similar topics

6
3252
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
9
3585
by: msnews.microsoft.com | last post by:
Hello! I'm Jim by asp How can show "abc" in textbox when click one botton?
21
66800
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what are the other approaches. please advise. thanks!!
1
3866
by: srinu | last post by:
Hello, We had one webserver based on a linux machine. The website is fully function and designed by a different person. Now we moved the machine from one IP to another one. I changed the machine ip address and the website is working partially. That site is working in between pages verywell. But once I give some input and requrest for data it is failing with the following message:
7
1792
by: Kirt | last post by:
i have walked a directory and have written the foll xml document. one of the folder had "&" character so i replaced it by "&amp;" #------------------test1.xml <Directory> <dirname>C:\Documents and Settings\Administrator\Desktop\1\bye w&amp;y </dirname> <file> <name>def.txt</name> <time>200607130417</time> </file>
5
7155
by: Damiano ALBANI | last post by:
Hello, I'd like to write a single XML Schema for both these documents : <Items> <Item xml:id="id1"> <Name>ABC</Name> ... </Item> <Item xml:id="id2">
9
4370
by: Steve | last post by:
Hi; I've being going through some legacy code on an old JSP site I have been patching. I noticed that when I save the JSP down to my PC as an HTML file I get this javascript error in IE 6 ( not in the latest Firefox ): "invalid character" The problem traces back to this line of code:
7
2442
by: MLH | last post by:
If I drop Like "*ABC*" in a QBE grid criteria cell, the records returned include mixed case. Can I force the uppercase limitation in a QBE grid?
7
3751
by: neovantage | last post by:
Hey all, I am creating a xml file in this format <?xml version="1.0" encoding="utf-8" standalone="yes"?> <customers> <customer> <category>Brosch&uuml;ren</category> <number>4</number> <email>abc@xyz.net</email>
0
8182
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8130
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
8627
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
8579
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
8279
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
8433
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7093
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...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1747
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.