On 29/03/2005 22:18,
gr********@gmail.com wrote:
[snip]
<URL: http://jibbering.com/faq/faq_notes/square_brackets.html >
Hmm... I tried it like the FAQ said, but still no luck.
Presumably you haven't changed your function calls so that you're
passing string literals not identifiers.
onkeyup="color(v1)"
The script engine will be trying to find - and failing, too - a
variable named v1. Quote it with single quotes.
Would you mind posting a working version of the code I posted?
An example might be in order as there are other issues.
1) You seem to be trying to use the id attribute values of the
two DIV elements as global variables. Don't. That's nonsense
introduced by Microsoft that you'd do well to avoid.
2) Disabling a form control in the mark-up itself is not
something you should do in any environment where you cannot
guarantee script support. Namely, the Web. If you're going to
need a script to enable something, or show something, you
should also use a script to disable or hide that thing in the
first place.
3) You can avoid worrying about the name or id attributes of
elements by passing a reference to the function and using the
DOM to access those element according to their structural
relationship. The example below demonstrates this.
It would seem that you're trying to colour around controls which have
values. A nicer approach than using DIVs would be to use LABELs. If
necessary, you can always make them block-level (using the a "display:
block" declaration in your style sheet) if need be. Also, if you want
some padding underneath the controls, use padding not a forced line break.
function highlight(control) {var colour, label;
/* Control is a reference to the form control.
* If its value is not an empty string, use a
* light grey...
*/
if(control.value) {colour = '#c0c0c0';}
/* ...otherwise use white. */
else {colour = '#ffffff';}
/* If we can obtain a reference to the parent node (the
* LABEL element), and that node has a style object...
*/
if((label = control.parentNode) && label.style) {
/* ...set the background colour to the previously
* determined colour.
*/
label.style.backgroundColor = colour;
}
}
<label>Name of vendor:
<input type="text" name="iv1" onkeyup="highlight(this);">
</label>
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.