amykimber@gmail.com wrote:
[color=blue]
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <title></title>[/color]
<URL:http://www.w3.org/QA/Tips/good-titles>
And a bit more indentation would be better.
[color=blue]
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">[/color]
Can/should be omitted if served via HTTP at first; send the correct
HTTP header instead, it will take precedence over this anyway.
[color=blue]
> <style>[/color]
The `type' attribute is required for `style' and `script' elements:
<style type="text/css">
See also <URL:http://validator.w3.org/>.
[color=blue]
> <!--
> input_to_text {
> background: pink;[/color]
This color name is not yet part of a Web standard, and it is intended for
for SVG, not HTML:
<URL:http://www.w3.org/TR/css3-color/#svg-color>
Do not rely on it. (The color value it represents is not Truly Web-safe
anyway; the nearest Truly Web-safe color value is #fcc.)
If you declare only the background color, use `background-color' instead
of `background'. And if you declare the background color, declare the
foreground colors as well (and vice-versa):
<URL:http://www.w3.org/QA/Tips/color>
[color=blue]
> }
> -->
> </style>
>
>
> <script>[/color]
See above.
<script type="text/javascript">
[color=blue]
> function change_class(var_type)
> {
> // both of these alerts give me 7[/color]
Do not indent your code using tabs (at least not when posting), use
multiples of 2 or 4 spaces.
[fixed indentation][color=blue]
> alert('dom = '+document.getElementsByName('ship_owner[]').length);
> alert('js = '+document.forms[0].elements['ship_owner[]'].length);
>
> if (var_type == 'block')
> {
> alert('proof I get to here')
> var inputs = document.getElementsByName("ship_owner[]");[/color]
Since this relies on W3C DOM Level 1, it will break in older
user agents, although it could have been avoided (see below):
function change_class(o, var_type)
{
if (o && o.form && o.form.elements)
{
if (var_type == 'block')
{
// ...
var inputs = o.form.elements["ship_owner[]"];
if (inputs)
{
[color=blue]
> for (var i = 0; i < inputs.length; i++)
> {
> inputs[i].className = "input_to_text";
> }[/color]
Since order does not matter here,
for (var i = inputs.length; i--;)
{
inputs[i].className = "input_to_text";
}
is even more efficient. Be sure to feature-test the `className'
property before you access it.
[color=blue]
> [...]
> <form name="ship_reords" action="block_action.php" method="post">[/color]
Your `form' element probably does not need a name.
See <news:1868424.HQv9pSZS7r@PointedEars.de>, a.o.
[color=blue]
> <table border="1">[/color]
Use only CSS for formatting, not deprecated format attributes.
[color=blue]
> [...]
> <tr>
> <td>Alone Hammerhead</td>
> <td><input name="ship_owner[]" class="" value="Amy" /></td>[/color]
This is declared HTML, not XHTML. Omit the `/'. (In HTML, `<... />' is
equivalent to `<...>>' as per built-in SHORTTAG feature. It is only
that _Web browsers_ (only a subset of HTML user agents) tend to implement
HTML insufficiently, and then do error correction; avoid that.)
[color=blue]
> [...]
> <a href="#" onClick="change_class('block')" >Block mode</a>[/color]
You need to cancel the click event, else navigation to the undefined target
`#' will take place:
<a href="#" onClick="change_class('block'); return false;">Block mode</a>
However, this feature will not work without client-side script support at
all. So you should create the link with client-side scripting:
<script type="text/javascript">
document.write('<a href="#"'
+ ' onclick="change_class(this, \'block\'); return false;"'
+ '>Block mode<\/a>');
</script>
A (formatted) button would be better suited for the task, though:
<script type="text/javascript">
document.write('<input type="button"'
+ ' onclick="change_class(this, \'block\');"'
+ '>Block mode<\/a>');
</script>
[color=blue]
> <input type="submit" value="submit"/>[/color]
^
See above. And I got the idea that control labels should start uppercase.
PointedEars
--
Multiple exclamation marks are a sure sign of a diseased mind.
-- Terry Pratchett