Re: Acess Dynamically Created Elements
- From: "jshanman" <jcshanks@xxxxxxxxxxxxx>
- Date: 28 Feb 2006 10:40:56 -0800
bradb wrote:
This is the function that gets called to create the checkbox...
function ent_source(num) {
var str = "source_"+num;
var id_field = "src_over"+num;
var replace = "(Source Over?)<input type=checkbox id='"+id_field+"'
onClick='updateField("+id_field+")'>";
document.getElementById(str).innerHTML = replace;
}
And I get an error immediately after clicking the check box saying
something like:
Error: src_over10 is not defined
Its looking for the object or variable src_over10, you want it to pass
the string "src_over10".
So change this:
var replace = "(Source Over?)<input type=checkbox id='"+id_field+"'
onClick='updateField("+id_field+")'>";
To this:
var replace = "(Source Over?)<input type=checkbox id='"+id_field+"'
onClick='updateField(\'"+id_field+"\')'>";
Notice the two \' around the "+id_field+" , it's probably hard to see.
This will send the string "src_over10" to the updateField function,
which can be used with a getElementById.
You could also do this:
var replace = "(Source Over?)<input type=checkbox id='"+id_field+"'
onClick='updateField(this.id)'>";
Which will do the exact same thing, and save a millisecond or two.
- JS
http://www.endeavorpub.com
.
- Follow-Ups:
- Re: Acess Dynamically Created Elements
- From: Thomas 'PointedEars' Lahn
- Re: Acess Dynamically Created Elements
- From: bradb
- Re: Acess Dynamically Created Elements
- References:
- Acess Dynamically Created Elements
- From: bradb
- Re: Acess Dynamically Created Elements
- From: RobG
- Re: Acess Dynamically Created Elements
- From: bradb
- Acess Dynamically Created Elements
- Prev by Date: Re: XML & Javascript parser
- Next by Date: Call python script by javascript in html
- Previous by thread: Re: Acess Dynamically Created Elements
- Next by thread: Re: Acess Dynamically Created Elements
- Index(es):
Relevant Pages
|