473,467 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with calling a function within a newly created element

DL
Hi,

What I wanted to do is to call a function from a newly created
element. But it stumbled me.

Here's the line that references the newly created element and I used
the alert function for debugging for now. Did I mess up all these
quotes?

// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';

Thanks.
Jun 27 '08 #1
22 1663
DL
On May 17, 6:52*pm, DL <tatata9...@gmail.comwrote:
Hi,

What I wanted to do is to call a function from a newly created
element. * But it stumbled me.

Here's the line that references the newly created element and I used
the alert function for debugging for now. * Did I mess up all these
quotes?

// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';

Thanks.
Ok, so, it looks like I wasn't thinking, the Event handler within the
newly created element hasn't been loaded by a browser, hence, no
action upon such an event. Yes? And if so, how do we solve this
problem? Or another better approach to achieve the same goal?

Thanks.
Jun 27 '08 #2
DL wrote:
What I wanted to do is to call a function from a newly created
element. But it stumbled me.

Here's the line that references the newly created element and I used
the alert function for debugging for now. Did I mess up all these
quotes?
Yes, you did.
// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
^start end^ ^start
\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
end^ ^start[1] ^^^[2]
selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';
^end

There. Because you have not properly delimited all your attribute values
[^1], you will generate

<select name=qType42onchange="alert(i);">

if i == 42. What do you expect of the user agent to do here?

While delimiting all attribute values with " --

<select name="qType42"onchange="alert(i);">

-- or including the missing whitespace --

<select name=qType42 onchange="alert(i);">

-- or do both of them would be a quick fix, I strongly suggest you stop
cooking proprietary (innerHTML) tag soup and start using DOM Level 2 creator
and mutator methods instead. With a few user-defined wrappers they can be
even more efficient to use than what you have now.

http://www.w3.org/TR/DOM-Level-2-Core/

Furthermore, if you generate the identifier of `i' instead of the current
value of `i' [^2], it will be resolved on execution of the event handler
attribute value, which is probably not what you want here.

BTW, `<' and `>' do not need to be escaped in string literals; `</' (ETAGO)
should be escaped as `<\/' if the source code is within an HTML document.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #3
DL wrote:
On May 17, 6:52 pm, DL <tatata9...@gmail.comwrote:
>newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';

Ok, so, it looks like I wasn't thinking, the Event handler within the
newly created element hasn't been loaded by a browser, hence, no
action upon such an event. Yes?
Not quite. The event handler exists before, as native code. The event
handler attribute value is a string of characters that is passed on to the
script engine which uses it to generate a function (the primary event
listener) that is called by the event handler on event.

However, as the generated code lacks the `onchange' attribute due to missing
separation of the relevant HTML code from the rest here, there is nothing to
pass on to the script engine, and no primary event listener is being created
that could be called on event.
Or another better approach to achieve the same goal?
See my other followup.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #4
Thomas 'PointedEars' Lahn wrote:
DL wrote:
>On May 17, 6:52 pm, DL <tatata9...@gmail.comwrote:
>>newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';
Ok, so, it looks like I wasn't thinking, the Event handler within the
newly created element hasn't been loaded by a browser, hence, no
action upon such an event. Yes?

Not quite. The event handler exists before, as native code. The event
handler attribute value is a string of characters that is passed on to the
script engine which uses it to generate a function (the primary event
^^^^^^^^^^^
"to create" is the better, less confusing verb here.
listener) that is called by the event handler on event.

PointedEars
Jun 27 '08 #5
DL
On May 17, 9:08*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
DL wrote:
What I wanted to do is to call a function from a newly created
element. * But it stumbled me.
Here's the line that references the newly created element and I used
the alert function for debugging for now. * Did I mess up all these
quotes?

Yes, you did.
// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:

* * * * * * * * * * *^start * * * * * * * * *end^ * ^start\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"

* * * * * * * * * end^ * *^start[1] * * * ^^^[2]selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^end

There. *Because you have not properly delimited all your attribute values
[^1], you will generate

* <select name=qType42onchange="alert(i);">

if i == 42. *What do you expect of the user agent to do here?

While delimiting all attribute values with " --

* <select name="qType42"onchange="alert(i);">

-- or including the missing whitespace --

* <select name=qType42 onchange="alert(i);">

-- or do both of them would be a quick fix, I strongly suggest you stop
cooking proprietary (innerHTML) tag soup and start using DOM Level 2 creator
and mutator methods instead. *With a few user-defined wrappers they can be
even more efficient to use than what you have now.

http://www.w3.org/TR/DOM-Level-2-Core/

Furthermore, if you generate the identifier of `i' instead of the current
value of `i' [^2], it will be resolved on execution of the event handler
attribute value, which is probably not what you want here.

BTW, `<' and `>' do not need to be escaped in string literals; `</' (ETAGO)
should be escaped as `<\/' if the source code is within an HTML document.
Ok, many thanks. Now, I changed part of it to
... <select name=qType'+i+' onchange="doCheckbox('+i+')"><option ...

This event handler is now recognized by my browser (IE7), however, I'm
getting "Object expected" error, fyi, the doCheckbox function (as a
sub function) looks this:

function doCheckbox(i) {
// debug
alert(i);
// add a new checkbox here
/* ... */
}

Jun 27 '08 #6
DL
On May 17, 9:47*pm, DL <tatata9...@gmail.comwrote:
On May 17, 9:08*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:


DL wrote:
What I wanted to do is to call a function from a newly created
element. * But it stumbled me.
Here's the line that references the newly created element and I used
the alert function for debugging for now. * Did I mess up all these
quotes?
Yes, you did.
// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
* * * * * * * * * * *^start * * * * * * * * *end^ * ^start\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
* * * * * * * * * end^ * *^start[1] * * * ^^^[2]selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^end
There. *Because you have not properly delimited all your attribute values
[^1], you will generate
* <select name=qType42onchange="alert(i);">
if i == 42. *What do you expect of the user agent to do here?
While delimiting all attribute values with " --
* <select name="qType42"onchange="alert(i);">
-- or including the missing whitespace --
* <select name=qType42 onchange="alert(i);">
-- or do both of them would be a quick fix, I strongly suggest you stop
cooking proprietary (innerHTML) tag soup and start using DOM Level 2 creator
and mutator methods instead. *With a few user-defined wrappers they can be
even more efficient to use than what you have now.
http://www.w3.org/TR/DOM-Level-2-Core/
Furthermore, if you generate the identifier of `i' instead of the current
value of `i' [^2], it will be resolved on execution of the event handler
attribute value, which is probably not what you want here.
BTW, `<' and `>' do not need to be escaped in string literals; `</' (ETAGO)
should be escaped as `<\/' if the source code is within an HTML document..

Ok, many thanks. *Now, I changed part of it to
... <select name=qType'+i+' onchange="doCheckbox('+i+')"><option ...

This event handler is now recognized by my browser (IE7), however, I'm
getting "Object expected" error, fyi, the doCheckbox function (as a
sub function) looks this:

function doCheckbox(i) {
* // debug
* *alert(i);
* // add a new checkbox here
* /* ... */

}- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
ok, I've fixed this problem by making the doCheckbox() a separate
function . Now,
with the doCheckbox() function,

If my code looks like the following,
if (document.getElementById('qType'+i).value = 'CK') {
var TBL = document.getElementById('tbl');
...
}
I got "document.getElementById(...)" is null or an object err but if I
comment out the IF line
if (document.getElementById('qType'+i).value = 'CK')
then the code works but I lose the logic of adding the checkbox only
when type is checkbox. Why?

Thanks.
Jun 27 '08 #7
DL
On May 17, 10:35*pm, DL <tatata9...@gmail.comwrote:
On May 17, 9:47*pm, DL <tatata9...@gmail.comwrote:


On May 17, 9:08*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
DL wrote:
What I wanted to do is to call a function from a newly created
element. * But it stumbled me.
Here's the line that references the newly created element and I used
the alert function for debugging for now. * Did I mess up all these
quotes?
Yes, you did.
// once again this is the key line of code, problem area, disregard
var i etc...
newTRc1.innerHTML ='\<input type="text" name=q'+i+' size="60"\>;Type:
* * * * * * * * * * *^start * * * * * * * * *end^ * ^start\<select name=qType'+i+ 'onchange="alert(i);"\>\<option value="YN"
* * * * * * * * * end^ * *^start[1] * * * ^^^[2]selected\>Yes/No\<option value="CK"\>Checkbox\</select\><br\>';
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^end
There. *Because you have not properly delimited all your attribute values
[^1], you will generate
* <select name=qType42onchange="alert(i);">
if i == 42. *What do you expect of the user agent to do here?
While delimiting all attribute values with " --
* <select name="qType42"onchange="alert(i);">
-- or including the missing whitespace --
* <select name=qType42 onchange="alert(i);">
-- or do both of them would be a quick fix, I strongly suggest you stop
cooking proprietary (innerHTML) tag soup and start using DOM Level 2 creator
and mutator methods instead. *With a few user-defined wrappers they can be
even more efficient to use than what you have now.
>http://www.w3.org/TR/DOM-Level-2-Core/
Furthermore, if you generate the identifier of `i' instead of the current
value of `i' [^2], it will be resolved on execution of the event handler
attribute value, which is probably not what you want here.
BTW, `<' and `>' do not need to be escaped in string literals; `</' (ETAGO)
should be escaped as `<\/' if the source code is within an HTML document.
Ok, many thanks. *Now, I changed part of it to
... <select name=qType'+i+' onchange="doCheckbox('+i+')"><option ...
This event handler is now recognized by my browser (IE7), however, I'm
getting "Object expected" error, fyi, the doCheckbox function (as a
sub function) looks this:
function doCheckbox(i) {
* // debug
* *alert(i);
* // add a new checkbox here
* /* ... */
}- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

ok, I've fixed this problem by making the doCheckbox() a separate
function . *Now,
with the doCheckbox() function,

If my code looks like the following,
if (document.getElementById('qType'+i).value = 'CK') {
* *var TBL = document.getElementById('tbl');
* *...}

I got "document.getElementById(...)" is null or an object err but if I
comment out the IF line
if (document.getElementById('qType'+i).value = 'CK')
then the code works but I lose the logic of adding the checkbox only
when type is checkbox. *Why?

Thanks.- Hide quoted text -
Ahe, now I think I know why the above IF statement failed because it's
not a simple value, the SELECT element may multiple values...
Jun 27 '08 #8
DL wrote:
On May 17, 10:35 pm, DL <tatata9...@gmail.comwrote:
>If my code looks like the following,
if (document.getElementById('qType'+i).value = 'CK') {
var TBL = document.getElementById('tbl');
...}

I got "document.getElementById(...)" is null or an object err but if I
^^^^^^^^^^^^
"... or _not_ an object"
>comment out the IF line
if (document.getElementById('qType'+i).value = 'CK')
then the code works but I lose the logic of adding the checkbox only
when type is checkbox. Why?

Ahe, now I think I know why the above IF statement failed because it's
not a simple value, the SELECT element may multiple values...
No, it is because document.getElementById('qType'+i) cannot be evaluated to
an object reference, as the error message says. So either there exists no
element with that ID (yet), or your markup is not Valid.

You have also assigned a value (`=') when you wanted a comparison (`==' or
`===').

BTW, full-quoting hundreds of unnecessary lines is not going to encourage
people to read your postings, much less to reply to them.

http://jibbering.com/faq/
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #9
DL
On May 18, 7:29*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
comment out the IF line
if (document.getElementById('qType'+i).value = 'CK')
then the code works but I lose the logic of adding the checkbox only
when type is checkbox. *Why?
Ahe, now I think I know why the above IF statement failed because it's
not a simple value, the SELECT element may multiple values...

No, it is because document.getElementById('qType'+i) cannot be evaluated to
an object reference, as the error message says. *So either there exists no
element with that ID (yet), or your markup is not Valid.

You have also assigned a value (`=') when you wanted a comparison (`==' or
`===').

BTW, full-quoting hundreds of unnecessary lines is not going to encourage
people to read your postings, much less to reply to them.

http://jibbering.com/faq/
Thanks a lot. So, how do I reference a dynamic ID? Let's continue to
use this case, the following line attempts to put a string literal
inside a simgle quotes then add the var i value then single quote the
whole "thing", won't work
document.getElementById(''qType'+i+'').value

Jun 27 '08 #10
DL
What's wrong with the following?

function addNewElements(i) {

var qt = 'qType'+i; // var for dynamic field id and name
if (document.getElementById(qt).value == 'CK')
// the if statement fails with IE7, not tested w/ other browsers
{ ... }

}

Thanks.
Jun 27 '08 #11
DL <ta********@gmail.comwrites:
What's wrong with the following?

function addNewElements(i) {

var qt = 'qType'+i; // var for dynamic field id and name
if (document.getElementById(qt).value == 'CK')
// the if statement fails with IE7, not tested w/ other browsers
what do you mean? if(condition) { implication } can't fail. it will
either evaluate condition to be true and then attempt to execute
implication or evaluate condition to be false and not execute
implication, and it can throw exceptions at any stage.

That's assuming the statement is valid code and parses at all.

In any case this looks like valid code, so the probably cause of
whatever it is that's happening is that qt does not refer to the id of
an element having a value attribute of "CK".

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #12
DL
On May 19, 5:38*pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
DL <tatata9...@gmail.comwrites:
What's wrong with the following?
function addNewElements(i) {
* var qt = 'qType'+i; // var for dynamic field id and name
* if (document.getElementById(qt).value == 'CK')
// the if statement fails with IE7, not tested w/ other browsers

what do you mean? if(condition) { implication } can't fail. it will
either evaluate condition to be true and then attempt to execute
implication or evaluate condition to be false and not execute
implication, and it can throw exceptions at any stage.

That's assuming the statement is valid code and parses at all.

In any case this looks like valid code, so the probably cause of
whatever it is that's happening is that qt does not refer to the id of
an element having a value attribute of "CK".

--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
ok, thanks, I think now I know what's going on. The 'qType'+i element
is a SELECT element with three options with values of ('YN' | 'CK' |
'RD'). Probaly the syntax of
document.getElementById(qt).value // qt being a var here
isn't correct, yes? If so, how do we deal with it?

Jun 27 '08 #13
DL wrote:
[...] So, how do I reference a dynamic ID? Let's continue to
use this case, the following line attempts to put a string literal
inside a simgle quotes then add the var i value then single quote the
whole "thing", won't work
document.getElementById(''qType'+i+'').value
^^^ ^^^ pointless, inefficient
||'-- syntax error
begin of string literal --''-- end of string literal

http://jibbering.com/faq/#FAQ4_43
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #14
DL <ta********@gmail.comwrites:
ok, thanks, I think now I know what's going on. The 'qType'+i element
is a SELECT element with three options with values of ('YN' | 'CK' |
'RD'). Probaly the syntax of
document.getElementById(qt).value // qt being a var here
isn't correct, yes? If so, how do we deal with it?
You're missing that select elements don't have a value; the options
have.

use something like this:

// get the <selectelement
var selectelement = document.getElementById(qt);
// now get the value of the selected <optionin that element
// assuming there's only one
var value = selectelement.options[selectelement.selectedIndex].value
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #15
Joost Diepenmaat wrote:
DL <ta********@gmail.comwrites:
>ok, thanks, I think now I know what's going on. The 'qType'+i element
is a SELECT element with three options with values of ('YN' | 'CK' |
'RD'). Probaly the syntax of
document.getElementById(qt).value // qt being a var here
isn't correct, yes? If so, how do we deal with it?

You're missing that select elements don't have a value; the options
have.
Not quite true.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-94282980

However, there is a catch with that in IE. I think I have posted an
explanation/test case before, but I can't seem to find it.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #16
DL
On May 19, 6:22*pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
DL <tatata9...@gmail.comwrites:
ok, thanks, I think now I know what's going on. *The 'qType'+i element
is a SELECT element with three options with values of ('YN' | 'CK' |
'RD'). *Probaly the syntax of
document.getElementById(qt).value // qt being a var here
isn't correct, yes? *If so, how do we deal with it?

You're missing that select elements don't have a value; the options
have.

use something like this:

// get the <selectelement
var selectelement = document.getElementById(qt);
// now get the value of the selected <optionin that element
// assuming there's only one
var value = selectelement.options[selectelement.selectedIndex].value

--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
Thanks. But I ran into a problem.

var qt = 'qType'+i;
alert(qt);
// so far so good, it generates a valid value of the SELECT element's
id;

var selectelement = document.getElementById(qt);
alert(selectelement);
// not good, it generates null value, hence, next step also failed.

Could the "pointed ear something" mess up my browser (his/her
javascript expertise is at a level to do something like that)?

Jun 27 '08 #17
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
Joost Diepenmaat wrote:
>DL <ta********@gmail.comwrites:
>>ok, thanks, I think now I know what's going on. The 'qType'+i element
is a SELECT element with three options with values of ('YN' | 'CK' |
'RD'). Probaly the syntax of
document.getElementById(qt).value // qt being a var here
isn't correct, yes? If so, how do we deal with it?

You're missing that select elements don't have a value; the options
have.

Not quite true.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-94282980

However, there is a catch with that in IE. I think I have posted an
explanation/test case before, but I can't seem to find it.
IIRC it didn't work reliably whenever it was that I fully tested it,
and it still doesn't work reliably now, while the selectedIndex has
worked for ages and continuous to work today. I'm also way too lazy to
test it again.

I'm probably overly cautious, but I don't expect anything after DOM-1
to work flawlessly in popular browsers.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #18
DL <ta********@gmail.comwrites:
Thanks. But I ran into a problem.

var qt = 'qType'+i;
alert(qt);
// so far so good, it generates a valid value of the SELECT element's
id;

var selectelement = document.getElementById(qt);
alert(selectelement);
// not good, it generates null value, hence, next step also failed.

Could the "pointed ear something" mess up my browser (his/her
javascript expertise is at a level to do something like that)?
Are you sure this is what's happening? At the risk of repeating
something someone already mentioned, the best practical way to check
is to use firefox with the firebug extension to check the _actual_ DOM
structure at the time of the execution of the code. your explanation
seems to indicate that there _isn't_ an element with the ID you
expect.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #19
DL
Thanks. *But I ran into a problem.
>
var qt = 'qType'+i;
* * alert(qt);
// so far so good, it generates a valid value of the SELECT element's
id;
var selectelement = document.getElementById(qt);
alert(selectelement);
// not good, it generates null value, hence, next step also failed.
Could the "pointed ear something" mess up my browser (his/her
javascript expertise is at a level to do something like that)?

Are you sure this is what's happening? At the risk of repeating
something someone already mentioned, the best practical way to check
is to use firefox with the firebug extension to check the _actual_ DOM
structure at the time of the execution of the code. your explanation
seems to indicate that there _isn't_ an element with the ID you
expect.

--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
Ahe. I know where the problem is... maybe...
Here's the code for this portion,
<select id="qType"+i name="qType"+i onchange="doCheckbox('+i
+','+nextrow+')"><option value="YN" selected>Yes/No<option
value="CK">Checkbox<option value="RD">Radio</select>

// silly me, the form wasn't sent, how to expect an element of it?
// now, I only need this SELECT element for the doCheckbox function,
could I re-write the above code to
<select id="qType"+i name="qType"+i
onchange="doCheckbox(this.value,'+i+','+nextrow+') "><option value="YN"
selected>Yes/No<option value="CK">Checkbox<option value="RD">Radio</
select>
to pass the SELECT element's value along?

My test indicates no. Then how?

Unfortunately the other viable alternative of using Firefox with
Firebug isn't available at this point. A company called Aka???
embeded encrypted code (probably to track what's going on with my FF
usage), but that's none of their f??? business and I cursed them
publicly, and they are security experts, now, my FF is hardly working,
let alone the powerful Firebug debugging feature). Trying the lame re-
installation to no avail...

Thanks.


Jun 27 '08 #20
DL
<select id="qType"+i name="qType"+i *onchange="doCheckbox('+i
+','+nextrow+')"><option value="YN" selected>Yes/No<option
value="CK">Checkbox<option value="RD">Radio</select>

// silly me, the form wasn't sent, how to expect an element of it?
// now, I only need this SELECT element for the doCheckbox function,
could I re-write the above code to
<select id="qType"+i name="qType"+i
onchange="doCheckbox(this.value,'+i+','+nextrow+') "><option value="YN"
selected>Yes/No<option value="CK">Checkbox<option value="RD">Radio</
select>
to pass the SELECT element's value along?
ok, the most desirable thing is to either send or somehow be able to
retrieve the newly populated value of the SELECT element from the
doCheckbox function. And if this option is a no go, send the whole
form? onchange="doCheckbox(form.submit(),'+i+','+nextrow +')"//
won't work
// it's about 10:24pm here, am I getting real slow?

Thanks.
Jun 27 '08 #21
DL wrote:
^^^^^^^^^
This is an attribution line. Again, please include one next time.
>>Thanks. But I ran into a problem.

var qt = 'qType'+i; alert(qt);
// so far so good, it generates a valid value of the SELECT element's
id;
As you have been told before, code should be posted so that it has good
chances to remain executable when copypasted, after being line-broken.
Therefore, single-line comments should appear *before* the code they
describe, and if they are long enough, multi-line comments /* ... */
should be used instead.
>>var selectelement = document.getElementById(qt);
alert(selectelement);
// not good, it generates null value, hence, next step also failed.

Could the "pointed ear something" mess up my
browser (his/her javascript expertise is at a level to do something
like that)?
So now you're blaming the result of your stupidity on the expertise of
others? (It's _he_ BTW, Thomas isn't a name you would give to a girl,
now is it?) :-(
>[...] your explanation seems to indicate that there _isn't_ an element
with the ID you expect.

Ahe. I know where the problem is... maybe... Here's the code for this
portion,

<select id="qType"+i name="qType"+i onchange="doCheckbox('+i
If an HTML parser were to parse this, it would read either

<select id="qType" name="qType" onchange="doCheckbox('+i

or

<select id="qType&quot;+i" name="qType&quot;+1" onchange="doCheckbox('+i

In the first case the element would not have the ID that you expect it to
have; in the second case the result is invalid as IDs must not contain the
`+' character. But see below.
+','+nextrow+')"><option value="YN" selected>Yes/No<option
value="CK">Checkbox<option value="RD">Radio</select>

// silly me, the form wasn't sent, how to expect an element of it? //
now, I only need this SELECT element for the doCheckbox function, could I
re-write the above code to <select id="qType"+i name="qType"+i
onchange="doCheckbox(this.value,'+i+','+nextrow+') "><option value="YN"
selected>Yes/No<option value="CK">Checkbox<option value="RD">Radio</
selectto pass the SELECT element's value along?

My test indicates no. Then how?
You have posted invalid HTML. Assuming in your favor that the code is a
string value that is the argument of document.write() or something like that
instead, you have forgotten to escape `</' (End TAG Open delimiter) as `<\/'
within that string.
Unfortunately the other viable alternative of using Firefox with Firebug
isn't available at this point. A company called Aka??? embeded encrypted
code (probably to track what's going on with my FF usage),
What the heck are you talking about? Do you want to be a serious software
developer, or do you want to be a script kiddie?
but that's none of their f??? business and I cursed them publicly, and
they are security experts, now, my FF is hardly working, let alone the
powerful Firebug debugging feature). Trying the lame re- installation to
no avail...
Maybe you should someone let do the job who knows what they are doing.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #22
DL
Unfortunately the other viable alternative of using Firefox with Firebug
isn't available at this point. A company called Aka??? embeded encrypted
code (probably to track what's going on with my FF usage),
What the heck are you talking about? Do you want to be a serious
software
developer, or do you want to be a script kiddie?
but that's none of their f??? business and I cursed them publicly, and
they are security experts, now, my FF is hardly working, let alone the
powerful Firebug debugging feature). *Trying the lame re- installationto
no avail...

Maybe you should someone let do the job who knows what they are doing.

PointedEars
--
Fk off, you m fker for the last time on your m's grave! I've asked
you to do so repeatedly in private but you did not listen, so, I have
to publicly! Once again, you m fker, fk off!!!!
Jun 27 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryan Stewart | last post by:
If you don't want to read this post because of its length, I understand. I've spent two and a half days on this problem and have a good deal of information to relate. And this is kind of a long...
4
by: thomastk | last post by:
Hi, In the following script, I am trying to set selection to a select option element, that is newly created within the script. It works fine on IE installations on Windows 2000 and some XP...
5
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
10
by: jaxent | last post by:
Does anyone know why IE gives the error "'document.myForm.dummy' is null or not an object" on the following page? Firefox does what I expect, creates a text box and writes "hello" in it. <html>...
1
by: mikejr83 | last post by:
I've been working on a project converting some IE code to be cross-browser complient. I've run into a little problem figuring out how to migrate the IE specific mergeAttributes function to...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
8
by: dd | last post by:
Hi, I've discovered a scenario where Safari 1.3 (I need to make my stuff compliant with 1.3+) gets confused about the scope of local variables WITHIN functions that were created in dynamic...
5
by: bizt | last post by:
Hi, Below I have a simple object / function thing (still getting head round these) declaration: function MyObject() { this.alertMe = function() { alert('hello'); }; this.alertMeAgain() {
3
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.