chitchirya Posted September 20, 2011 Share Posted September 20, 2011 Good day!This is my first time to post here in forums. Sorry for my bad english.Hopefully you can help me with my problem. This is my Function function showResult(class){alert(class);} This is my Php code; do{ echo "<input type='button' value=".$result['class_name']." name=".$result['class_name']." onclick='showResult(this.value)'>"; $result = mysql_fetch_assoc($query); }while($result); My button seems working properly but when I call the function during the event onClick, it does not work. Please help me. God bless all =) Link to comment Share on other sites More sharing options...
justsomeguy Posted September 20, 2011 Share Posted September 20, 2011 You should have quotes around the value and name, and you might need to use a function like str_replace to replace quotes with HTML entities. Link to comment Share on other sites More sharing options...
chitchirya Posted September 20, 2011 Author Share Posted September 20, 2011 It has already, value=".$result['class_name']." name=".$result['class_name']." its, inside a php code. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 20, 2011 Share Posted September 20, 2011 The quotes don't get printed in the HTML, they are quotes in PHP code. Look at the HTML that the code creates to see what actually gets sent to the browser. Link to comment Share on other sites More sharing options...
chitchirya Posted September 20, 2011 Author Share Posted September 20, 2011 Do you mean like this? value='".$result['class_name']."' name='".$result['class_name']."' It does not work also. but why this code work... <select name=".addslashes($result['skill_name'])." onChange='showRlvl(this.value,this.name); showEffect(this.value,this.name,".$result['skill_id']."); showPoints2(this.value)'> Link to comment Share on other sites More sharing options...
chitchirya Posted September 20, 2011 Author Share Posted September 20, 2011 Lol! Made it working, I just added id=".$result['class_name']." btw, thanks alot for helping =) EDIT: also, variable class makes my code don't work so I made another variable in which javascript variables is not used. Sigh. Another lesson learned. =) Link to comment Share on other sites More sharing options...
tutorholic Posted September 22, 2011 Share Posted September 22, 2011 I think class is a javascript keyword.It cannot be used as variable names Link to comment Share on other sites More sharing options...
thescientist Posted September 22, 2011 Share Posted September 22, 2011 I think class is a javascript keyword.It cannot be used as variable names Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.