AnotherQuestion Posted August 25, 2009 Share Posted August 25, 2009 I have written a some code that is suppoed to call a javascript to submit a form if a value ==1 If ($totalRows_RsCustomer ==1 ){echo "<script language="javascript" type="text/javascript"> document.UserDetails.submit(); </script>";} At runtime i get an error "Document.Userdetails is null or not an object" Quote Link to comment https://forums.phpfreaks.com/topic/171857-solved-javascript-in-php/ Share on other sites More sharing options...
mikesta707 Posted August 25, 2009 Share Posted August 25, 2009 javascript and PHP don't play nice with each other most of the time. Make sure that your form is created before you write that statement. try posting your whole code Quote Link to comment https://forums.phpfreaks.com/topic/171857-solved-javascript-in-php/#findComment-906172 Share on other sites More sharing options...
AnotherQuestion Posted August 25, 2009 Author Share Posted August 25, 2009 thanks for info & quick reply it was as simple as "Make sure that your form is created before you write that statement" placed code just before </body> and all was well Quote Link to comment https://forums.phpfreaks.com/topic/171857-solved-javascript-in-php/#findComment-906221 Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 try this code <script type="text/javascript"> document.write( "<?php if($totalRows_RsCustomer ==1) { ?>"); document.UserDetails.submit(); document.write( "<?php } ?>"); </script> Quote Link to comment https://forums.phpfreaks.com/topic/171857-solved-javascript-in-php/#findComment-906227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.