newbie: help with forms

L

lee.munheng

hi everyone,

basically, the page layout uses absolute positioning with some forms on
the left and an embedded object on the right. but, when i load the
page, i get the following error.

Error: document.inputform has no properties ... Line: 10

i've tried using

window.document.inputform.externalID.readonly="readonly";

and even

document.forms['inputform'].elements['externalID'].readonly="readonly";

please help.
mh

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">

window.onload = function() {
document.inputform.externalID.readonly="readonly";
}

function doGreyout(value) {
switch(value) {
case "switch":
alert("switch");
break;
case "node":
alert("node");
break;
case "edge":
alert("edge");
document.inputform.externalID.readonly="readonly";
break;
default:
alert("no such option!");
}
}

function doNewInterface() {
}
</script>
</head>
<body>

<div id="sidebar1" style="position: absolute; top: 50px; left:
10px; width: 200px; height: 100%; border: 1px dashed blue; padding:
5px;">
<form name="nodetypeform">
<select name="nodeTypes"

onchange="doGreyout(this.options[this.selectedIndex].value);">
<option value="node">Node</option>
<option value="switch">Switch</option>
<option value="edge">Edge</option>
</select>
</form>

<form name="inputform">
<p>Name<br />
<input type="text" name="nodename" size="18"
maxlength="80"></input>
</p>
<p>External ID<br />
<input type="text" name="externalID" size="18"
maxlength="80"></input>
</p>
<p>Internal ID<br />
<input type="text" name="internalID" size="18"
maxlength="80"></input>
</p>
<p>Interfaces
<input type="button" value="Add"
onclick="doNewInterface"></input>
</p>
<p>
<input type="button" value="Create node"
onclick="window.doNewButton(this)">
</input>
</p>
</form>
</div>

<div id="sidebar2" style="position: absolute; top: 500px; left:
10px; width: 200px; height: 200px; border: 1px dashed blue">
</div>

<div id="SVGCanvas" style="position: absolute; top: 50px; left:
240px; width: 600px; height: 600px; border: 1px dashed blue">
<embed src="canvas.svg" width="600" height="600"
type="image/svg+xml"></embed>
<noembed>SVG Canvas</noembed>
</div>

</body>
</html>
 
R

Richard Cornford

basically, the page layout uses absolute positioning with some
forms on the left and an embedded object on the right. but,
when i load the page, i get the following error.

Error: document.inputform has no properties ... Line: 10

Your document claims to be XHTML. Obviously we don't have enough
information to tell whether it is really XHMTL or just HTML giving the
illusion of being XHTML but the above is a 'shrotcut' property accessor
for a form (as a named property of the document) and that may be
traditionally supported by HTML DOMs but it should not be expected to
be supported in XHTML DOMs.
i've tried using

window.document.inputform.externalID.readonly="readonly";

This is another 'shortcut' property accessor and so should not be
expected to be effective in an XHTML DOM.
and even

document.forms['inputform'].elements['externalID'].readonly="readonly";

While this one is DOM standard and so should 'work' as far as accessing
the form element goes. You did not specify which, if any, error it
generated, or whether it is just ineffective.

It will be ineffective as the property of a form control element that
corresponds with its readonly attribute is - readOnly - in case
sensitive javascript, and it is a boolean value so assigning a
non-empty string to the value is effectively (through automatic
type-conversion) always setting it to boolean true.

document.forms['inputform'].elements['externalID'].readOnly = true;

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form name="nodetypeform">
<snip>

In valid (x)HTML a FORM element should have the required - action -
attribute.

Richard.
 
L

lee.munheng

hi Richard,

many thanks for for your help. removing the the doctype and namespace
declarations on top making it plain old html seem to have solved
problem (and several others as well).

many thanks again.

mh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,267
Latest member
WaylonCogb

Latest Threads

Top