Forum Moderators: coopster

Message Too Old, No Replies

PHP execution on a checkbox

         

andrewsmd

8:52 pm on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there anyway to execute php on a checkbox click. Right now use JavaScript to call an external PHP file which in turn outputs it's output in JavaScript back to the browser. Is there a way to do all of this with PHP. I'm not sure where PHP is executed on the server side. Thanks,

Receptional Andy

8:54 pm on Oct 27, 2008 (gmt 0)



PHP is only on the server side. The only possible way you can get interaction via PHP is via a link or form submission that causes an additional request from client to server. Javascript is the best method to track other kinds of interaction with elements of a page. Your current implementation sounds fine to me.

dreamcatcher

8:55 pm on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ajax is probably the way to go, but thats technically js, so probably best how you have it. Ajax can easily execute php code via the onclick method and fetch data from a php file.

Any reason for wanting to change?

dc

andrewsmd

1:00 pm on Oct 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well right now I work around everything by echoing either alert boxes or inserting inner html to hidden divs. That is how I format my text with the JS when the output comes from php. I just thought maybe I could get rid of the JS and just use PHP because then I could use templates and shorten up my HTML page immensely. Basically right now I have something along the lines of this.
<tr>

<td class = "text">Anthem Midwest - HyperAccess<a class = "info" href=#>help<span class = "spanClass">To send Anthem Midwest, run the Download Anthem
Midwest BBS Receiver job in EC Client and then the M - Transmit - Anthem Midwest job in Hyperaccess. Make sure you get the acknowledgement "MAILIT^M". If
it quits in the middle of sending, just click the Fix Anthem Midwest button and it should tell you that it deleted a zip file and moved some edi files to
the output. If not, then there could be a problem. When your done, click the checkbox and Michael's programs will check everything for you. </span></a></td>
<td class = "checkBox"><input type="checkbox" name="anthemMidwest" <?php echo($_SESSION['anthemMidwestCheck']); ?>
onclick="if(this.checked){loadFile('anthemMidwest.php')}"></td>
<td class = "message">
<INPUT type="button" name = "anthemWestFix" value = "Fix Anthem Midwest" onclick="loadFile('anthemMidwestFix.php')" />
<div id = "anthemMidwestHidden"><?php echo($_SESSION['anthemMidwestSent']); ?></div></td>
</tr>
Now I have this repeated probably 50 or 60 times with just different text. The html layout is exactly the same. I just wanted to use a template to set all of that but that's ok. It works the way I use it now. I just wanted to make it better. Also, I don't like using JS and try to avoid it whenever I can.