Subtle Javascript Bug
-
This is the onclick event of a button on a form - Took awhile to figure out what was wrong ;P The checkform() function is irrelevant to the question.
onclick=" if ((document.getElementById('whereto').value) = 'rent') { void(document.getElementById('toRent').value='1'); } else { void(document.getElementById('toRent').value='0'); } checkform()"
-= Reelix =-
-
This is the onclick event of a button on a form - Took awhile to figure out what was wrong ;P The checkform() function is irrelevant to the question.
onclick=" if ((document.getElementById('whereto').value) = 'rent') { void(document.getElementById('toRent').value='1'); } else { void(document.getElementById('toRent').value='0'); } checkform()"
-= Reelix =-
Should it be
if ((document.getElementById('whereto').value) == 'rent')
? -
Should it be
if ((document.getElementById('whereto').value) == 'rent')
?Correct :) I was wondering why the value was never altered - Spent about 30 minutes searching through the "checkform()" procedure (around 200 LoC) - Scrutinizing every line - Double and triple checking to see if maybe, just maybe I had done something wrong... /facepalm
-= Reelix =-
-
This is the onclick event of a button on a form - Took awhile to figure out what was wrong ;P The checkform() function is irrelevant to the question.
onclick=" if ((document.getElementById('whereto').value) = 'rent') { void(document.getElementById('toRent').value='1'); } else { void(document.getElementById('toRent').value='0'); } checkform()"
-= Reelix =-
Which is why I tend to write it thus:
'rent' == (document.getElementById('whereto').value)
Makes mistakes much more obvious.10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
-
Which is why I tend to write it thus:
'rent' == (document.getElementById('whereto').value)
Makes mistakes much more obvious.10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
-
Hmm - Will try that in the future :) On a side note, are you aware your signature translates to:
³>ª4¢ ��<X²
:)
-= Reelix =-
Sure doesn't. There's a message in there.
10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
-
Sure doesn't. There's a message in there.
10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
-
Hmm - Will try that in the future :) On a side note, are you aware your signature translates to:
³>ª4¢ ��<X²
:)
-= Reelix =-
Found the same string.
-
Correct :) I was wondering why the value was never altered - Spent about 30 minutes searching through the "checkform()" procedure (around 200 LoC) - Scrutinizing every line - Double and triple checking to see if maybe, just maybe I had done something wrong... /facepalm
-= Reelix =-
-
Which is why I tend to write it thus:
'rent' == (document.getElementById('whereto').value)
Makes mistakes much more obvious.10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011