0

Hi, please help me with my code.

Javascript function
if (document.myform.Available.checked == false) {
document.myform.Save.disabled = true;
<?php
$query = mysql_query("UPDATE rewarditems SET Available = 'Yes' WHERE RewardItemID = '{$_GET}'",$link1) or die(mysql_error());
?>
}
else if (document.myform.Available.checked == true) {
document.myform.Save.disabled = false;
<?php
$query = mysql_query("UPDATE rewarditems SET Available = 'No' WHERE RewardItemID = '{$_GET}'",$link1) or die(mysql_error());
?>
}

can this be done?

thanks

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by ko ko
0

this is not possible.
When your page is rendered to client browser, It will execute php code first at server side and produce html source code for browser.

When php execution is over then page is in ready state.

NOw javascript/html takes up the job.

To execute php query, you must submit a form, then exeute query in another or same php file using post/get fields.

Edited by urtrivedi: n/a

0

@urtrivedi,

can this be done in <input type='checkbox' onclick=''> ?

thanks

0

What can be done with your post ? The PHP statement cannot work inside the JS function. Javascript only work on browser (client), PHP work on server (web-server). You should make a function that collect the data and send this data to the php file that you want to process.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.