XHTML Strict and Script

T

Tom

Hi,

XHTML depreciates "name" and "target" for FORM. Most javascripts that
interact with FORM make heavy use of "name" to know which form to interact
with. You can use ID to 'name' a form, but javascript does not recognize
"id".

I have not been able to find any discussions of how to get around these
obstacles. Does anyone have any websites to review or suggestions?

Tom
 
T

Tom

Leif K-Brooks said:
Yes it does, document.getElementById().

OK, here is the code:

<form id="form3" action="url">
<select name="pblinks" size="1">
<option selected value="#">Select the size...</option>
<option value="url">1.0 L - $19.90</option>
<option value="url">1.5 L - $29.85</option>
<option value="url">2.0 L - $39.80</option>
<option value="url">3.0 L - $59.70</option>
</select><br />
<input id="button" type="button" value="Buy Now"
onclick="window.open(document.getelementbyid().pblinks.options[document.gete
lementbyid().pblinks.selectedIndex].value);" />
</form>

Is this the proper use of the getelementbyid()?

Thanks for the help...Tom
 
V

Vjekoslav Begovic

Tom said:
<input id="button" type="button" value="Buy Now"
onclick="window.open(document.getelementbyid().pblinks.options[document.gete
lementbyid().pblinks.selectedIndex].value);" />
</form>

Is this the proper use of the getelementbyid()?

No, use:

document.getElementById('pblinks').

Also, notice that JavaScript is case-sensitive.
 
K

Kris

"Tom" <[email protected]> said:
<form id="form3" action="url">
<select name="pblinks" size="1">
<option selected value="#">Select the size...</option>
<option value="url">1.0 L - $19.90</option>
<option value="url">1.5 L - $29.85</option>
<option value="url">2.0 L - $39.80</option>
<option value="url">3.0 L - $59.70</option>
</select><br />
<input id="button" type="button" value="Buy Now"
onclick="window.open(document.getelementbyid().pblinks.options[document.gete
lementbyid().pblinks.selectedIndex].value);" />
</form>

Is this the proper use of the getelementbyid()?

This is improper use of javascript. The form will not work without it
and that is totally unneccesary.

<form action="serverSideHandler.php" method="post"
onsubmit="if(document.getElementById) {
window.open(document.getElementById('pblinks').selectedIndex.value);
return false; }">
<select name="pblinks" id="pblinks" size="1">
<option selected>Select the size...</option>
<option value="http://www.textarea51.com/1">1.0 L - $19.90</option>
<option value="http://www.textarea51.com/2">1.5 L - $29.85</option>
<option value="http://www.textarea51.com/3">2.0 L - $39.80</option>
<option value="http://www.textarea51.com/4">3.0 L - $59.70</option>
</select><br />
<input type="submit" value="Buy Now" />
</form>

serverSideHandler.php:
<?
if($pblinks) {
header("Location: ".$pblinks);
} else header("Location: ".$HTTP_REFERER);
?>

Something like this. I may have screwed up in one place or the other,
since I did not test this.
 
B

Bertilo Wennergren

Tom:
XHTML depreciates "name" and "target" for FORM. Most javascripts that
interact with FORM make heavy use of "name" to know which form to interact
with. You can use ID to 'name' a form, but javascript does not recognize
"id".

Of course Javascript recognizes "id".
I have not been able to find any discussions of how to get around these
obstacles.

In XHTML 1.0 Transitional you can use both "name" and "target" in forms.
The same goes for HTML 4.01 Transitional.

"Target" is missing for forms in HTML 4.01 Strict, as well as in XHTML
1.0 Strict.
 

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,280
Latest member
BGBBrock56

Latest Threads

Top