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

Recommended Answers

All 3 Replies

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.

@urtrivedi,

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

thanks

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.