powpow Posted February 10, 2011 Share Posted February 10, 2011 I am having issue creating a checkbox that uses a onClick() js method. I believe this might be due to the fact that I am echoing the html but if any one could help id appreciate it. echo "<tr><td>WrkComp</td><td><input type='checkbox'" ?> <script>onClick="show()" </script> <? "name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>"; Link to comment https://forums.phpfreaks.com/topic/227251-echoing-a-checkbox-with-js-in-it/ Share on other sites More sharing options...
pornophobic Posted February 10, 2011 Share Posted February 10, 2011 I don't see why you are including you onclick in script tags? echo '<tr><td>WrkComp</td><td><input type="checkbox" onclick="show()" name="WrkComp[]" value="DEP" ' . $checked . ' ' . $Disabled . '/></td>'; Edit: onclick validates where onClick does not. Link to comment https://forums.phpfreaks.com/topic/227251-echoing-a-checkbox-with-js-in-it/#findComment-1172273 Share on other sites More sharing options...
solon Posted February 10, 2011 Share Posted February 10, 2011 Just do the following: When echoing a onclick() event in your code you dont need to do anything different than what you do when echoing lets say 'name' pr any other attribute name of a tag. echo "<tr><td>WrkComp</td><td><input type='checkbox' onClick='show()' name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>"; Link to comment https://forums.phpfreaks.com/topic/227251-echoing-a-checkbox-with-js-in-it/#findComment-1172274 Share on other sites More sharing options...
powpow Posted February 10, 2011 Author Share Posted February 10, 2011 Well some how through my problem solving I skipped step 1. Thank you for your solutions. Edit: onclick validates where onClick does not. Can you supply me a link about onclick? I did a quick "onclick vs onClick" google search and nothing came up. Thanks again! Link to comment https://forums.phpfreaks.com/topic/227251-echoing-a-checkbox-with-js-in-it/#findComment-1172288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.