Click to See Complete Forum and Search --> : can't get this thing working
michal2212
03-23-2005, 12:42 PM
Hi everybody,
I've got something like this:
<html>
<?php
echo '<form name="test" method="post">';
echo '<select name="choice" size="1" onChange="if (this.selectedIndex == 3) document.test.choose.disabled=false; else document.test.choose.disabled=true;">';
echo '<option name="hello">hello</option>';
echo '<option name="bye">bye</option>';
echo '<option name="what">what</option>';
echo '<option name="other">other</option>';
echo '</select><input type="text" name="choose" disabled>';
echo '</form>';
?>
</html>
and it's working fine until it's a part of bigger file. Then I keep getting error from IE: 'document.test.choose' is null or is not an object.
That bigger file doesn't contains some special tricks, only usual if-else instructions and stuff like this...
Does anyone have some idea why it doesn't work ?
tekky
03-23-2005, 12:49 PM
why not try this...
<html>
<form name="test" method="post">
<select name="choice" size="1" onChange="if (this.selectedIndex == 3) document.test.choose.disabled=false; else document.test.choose.disabled=true;">
<option name="hello">hello</option>
<option name="bye">bye</option>
<option name="what">what</option>
<option name="other">other</option>
</select><input type="text" name="choose" disabled>
</form>
</html>
you have no PHP in there.. so why waste time using it?
michal2212
03-23-2005, 12:56 PM
There's a PHP code in the bigger version... It's quite long so I didn't list it here... But I definitely need it working in PHP
tekky
03-23-2005, 01:31 PM
yes but there is no php THERE so why try and parse it as PHP you are just asking for more trouble, as it stands, you have NO problem, there is nothing to error in that sections as long as you do it like I just did
remember the old acroynm KISS?
bubblenut
03-23-2005, 08:34 PM
I know tekky's too nice to point it out but I'm not so tough luck! ;)
This isn't really the correct forum for what you've posted. This is supposed to be a place where people can show completed code to their peirs for comments and advice.
There are the Nebies, General Help and Coding forums for this kind of problem.
tekky
03-23-2005, 09:38 PM
Originally posted by bubblenut
I know tekky's too nice to point it out but I'm not so tough luck! ;)
Nah, that was the least of my concerns, I figured we could teach him to follow netiquette after we taught him the difference between HTML and PHP :evilgrin:
bubblenut
03-23-2005, 09:44 PM
Fair play, best to start at the basics :p
Weedpacket
03-23-2005, 10:19 PM
Originally posted by bubblenut
Fair play, best to start at the basics :p Aye, like if this is supposed to be part of a bigger file, then the <html> tags shouldn't be there.
bubblenut
03-23-2005, 10:40 PM
Well if we're doing what the code critique forum is for then lets go all the way. :D
This line isn't XHTML compatible
<input type="text" name="choose" disabled>
//it should be
<input type="text" name="choose" disabled />
Also, I'd say that the logic in your onclick should be taken out into a function, and disabled should have a value (ie. disabled="disabled")
tekky
03-23-2005, 10:55 PM
Originally posted by bubblenut
.....and disabled should have a value (ie. disabled="disabled")
Wouldn't that mean that you enabled it? I mean if you disable a disabled property... disabled === false then right? so shouldnt disabled=true? :evilgrin:
bubblenut
03-23-2005, 10:59 PM
I'm not sure to be honest and it's too late for me to look it up now. I figured it was the same as with selected, where the old syntax was just "selected" but the xhtml sytax is 'selected="selected"'.
Weedpacket
03-25-2005, 07:04 AM
Originally posted by bubblenut
I figured it was the same as with selected, where the old syntax was just "selected" but the xhtml sytax is 'selected="selected"'. It is (all XML attributes must have values); but from the investigations I've just done (i.e., absolutely none), you could have 'disabled="nullus anum rodentum"' and it would work.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.