Closed Thread Icon

Topic awaiting preservation: damn EventHandler !!! Pages that link to <a href="https://ozoneasylum.com/backlink?for=8614" title="Pages that link to Topic awaiting preservation: damn EventHandler !!!" rel="nofollow" >Topic awaiting preservation: damn EventHandler !!!\

 
Author Thread
norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-23-2003 05:35

for some reason the following code:

document.forms[0].elements[0].onchange=doIt;

does not fire the function called doIt(). If I do something like :

<input type="text" name="person" value=" " size="20" maxlength="40"onchange="doIt()">

it works. However, assigning the Event Handler in the tag is not an option I can use in this case, because I plan on using this block of javascript in RegisterStartupScript() for an ASP.net app.

According to my big fat( and usually accurate) O'Reilly book "document.forms[0].elements[0].onchange=doIt; " should work.

Help!! Help! please......

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-23-2003 05:39

It does look fine. At what point do you run that line of code?

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-23-2003 05:47

I've tried both of these , with no success:

<head>
<script>
function doIt(){
alert('SmartAss comment');
}

function front(){
document.forms[0].elements[0].onchange=doIt;
}
</script>
</head>
<body onload="front()">

and I tried

<head>
<script>
function doIt(){
alert('SmartAss comment');
}

document.forms[0].elements[0].onchange=doIt;
</script>
</head>

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-23-2003 06:10

GOT IT !!!!

sorry I know I shouldn't shout like that, but after 2 1/2 hrs......

Turns out I do have to put it in a function, but even more importantly- " forms[0]" works much better than "form[0]".

Yep, one stupid little typo.

if (page==sloppyCode){
alert('Norm, you're an imbecile');
}

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-23-2003 06:42

Two and a half hours from a missing "s"?

Bah, that's nothing... I once sank about 4 hours into a minus (-) sign.

I'm proud of that minus sign.... =\

[This message has been edited by Dracusis (edited 04-23-2003).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-23-2003 19:23

Hah! That's nothing. I once spent about 12 hours debugging the Slime-POV source code because I didn't understand what a C++ "union" was!

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-23-2003 19:51

bah see I once spent 2 weeks 4 days and 23 hours debugging a FORTRAN script for a missing semi-colon.

Actually I found out a long time ago that if I can't figure it out to go ask someone. Not because they'll figure it out but because the instant I ask them the question I'll figure out the answer and feel like an idiot. (I think this must be one of Murphy's laws of programming)

But hey I may feel like an idiot but at least my code works and I didn't spend all day finding out why.



.:[ Never resist a perfect moment ]:.

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-24-2003 02:56

OK, I can see I have failed to impress anyone with my missing "s"..... I'll be sure and try again when I have more obvious and time consuming f***-up to report.

I do have some good MySQL screw-ups, but I have invested to much time into recovering from the mental trauma to actually bring them up again.

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

« BackwardsOnwards »

Show Forum Drop Down Menu