abbos Posted August 13, 2008 Share Posted August 13, 2008 Hi Everyone, Complete newbie here so please be patient I am creating somthing similar to a cart page and cannot seem to get the following line to work: echo "<td colspan=\"2\" align=\"right\"><form><input name=\"checkbox\" type=\"checkbox\" value\"showlabour\" onClick=\"if(CHECKED){$total=$totallinecost+$totallabourcost+$delivery}else{$total=$totallinecost+$delivery};\"></form>include labour</td>"; I want to put a checkbox on the page. If it is checked then it should do the first sum and then refresh the page, if it is unchecked it should do the second sum and refresh the page. Am I completely off track or nearly there? Thanks, Abbos Link to comment https://forums.phpfreaks.com/topic/119554-onclick-with-if-statement/ Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 You can't execute PHP onClick. >_> Link to comment https://forums.phpfreaks.com/topic/119554-onclick-with-if-statement/#findComment-615920 Share on other sites More sharing options...
abbos Posted August 13, 2008 Author Share Posted August 13, 2008 That explains things. Hmm... is there another way of putting a checkbox on a page and then testing is state using an if statement? Link to comment https://forums.phpfreaks.com/topic/119554-onclick-with-if-statement/#findComment-615924 Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 Javascript? Link to comment https://forums.phpfreaks.com/topic/119554-onclick-with-if-statement/#findComment-615930 Share on other sites More sharing options...
abbos Posted August 13, 2008 Author Share Posted August 13, 2008 Good thinking. It's late here in the UK and my brain has decided to pack up and go to bed although I'm still working. Thanks. Link to comment https://forums.phpfreaks.com/topic/119554-onclick-with-if-statement/#findComment-615933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.