Shamrox Posted January 22, 2007 Share Posted January 22, 2007 I'm trying to update the status of a record in my database using onClick to call a function I wrote, but it doesn't seem to do anything. What am I doing wrong here?Code for function:[code]function clear_record($id) { $sql = "UPDATE`spec_registrar` SET `surveystatus`= 'clear' WHERE `registrarid` = '$id';";}[/code]Code for calling it:[code]<input type="image" img src="images/admin_images/gridicon_delete.gif" alt="Clear from table" width="20" height="20" border="0" onClick="clear_record(<?php echo $row_rs_survey['registrarid']; ?>);"/>[/code] Quote Link to comment Share on other sites More sharing options...
lando Posted January 22, 2007 Share Posted January 22, 2007 I'm not sure I completely understand what you are trying to do here...Is the function clear_record() a PHP function? If that is the case you can not execute that function from an onClick event. The onClick event is a Javascript event, so you will need to use a Javascript function to trigger a remote PHP function. This can be done in a number of ways. You would use some sort of AJAX script, Javascript redirect (window.location=remote_url), or since you are using an input button you could simply submit the form to a remote PHP script. Quote Link to comment Share on other sites More sharing options...
franklyn Posted January 22, 2007 Share Posted January 22, 2007 Or just post the information to the same page and pass an id variable . Quote Link to comment Share on other sites More sharing options...
Shamrox Posted January 22, 2007 Author Share Posted January 22, 2007 is there any way to do it with a php function and not go to another page? What I'd like to see is the user clicks on the Clear icon and it removes the record from that table of data on the screen. Best/easiest method to do this? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 22, 2007 Share Posted January 22, 2007 You can remove whatever DOM elements you like before, during or after any server action. Quote Link to comment Share on other sites More sharing options...
lando Posted January 23, 2007 Share Posted January 23, 2007 If you are just wanting to remove it from a table that is displayed on the screen you would need to use some Javascript to modify the DOM. What is below is the basic structure of what you need. You will need to modify it to work with your page layout.element.removeChild(referenceToChildNode) Quote Link to comment 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.