matthewst Posted June 11, 2007 Share Posted June 11, 2007 It always says "nothing in text box" <input type="text" class="formSmallTextbox" name="a_number" size="4" value="<?="$a_number"?>"> <input type="submit" name="submit" class="formTextbox" value="Submit" onClick="<?php if ($qty_oak >= '1'){ echo "return confirm('something in text box')\">";} else{ echo "return confirm('nothing in text box')\">";} ?> Link to comment https://forums.phpfreaks.com/topic/55098-solved-if-statement-in-onclick-event/ Share on other sites More sharing options...
matthewst Posted June 11, 2007 Author Share Posted June 11, 2007 It just occurred to me that when the page loads the text box a_number is always empty thats why it echos "nothing in text box". How do I get php to recognize that something was put in the text box after the page was loaded? Link to comment https://forums.phpfreaks.com/topic/55098-solved-if-statement-in-onclick-event/#findComment-272355 Share on other sites More sharing options...
trq Posted June 11, 2007 Share Posted June 11, 2007 PHP is server side, so the onclick (Javascript) meens nothing to it. What exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/55098-solved-if-statement-in-onclick-event/#findComment-272359 Share on other sites More sharing options...
tarun Posted June 11, 2007 Share Posted June 11, 2007 You Could Use Ajax...? Link to comment https://forums.phpfreaks.com/topic/55098-solved-if-statement-in-onclick-event/#findComment-272365 Share on other sites More sharing options...
matthewst Posted June 11, 2007 Author Share Posted June 11, 2007 thanks raffels (sitepoint) <input type="text" class="formSmallTextbox" name="a_number" size="4" value=""> <input type="submit" name="submit" class="formTextbox" value="Submit" onClick="if (document.getElementsByName('a_number')[0].value == '') return confirm('nothing in text box'); else return confirm('something in textbox');"> Link to comment https://forums.phpfreaks.com/topic/55098-solved-if-statement-in-onclick-event/#findComment-272385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.