leijae Posted July 6, 2011 Share Posted July 6, 2011 I wrote this code in Javascript... I hate it, but I'm not really well versed in PHP. Is there a PHP equivalent? I'm not asking anyone to do it for me, but if you know of a resource that's good for this matter, please post it. // this is my javascript function hidey(val) { if(val == 'on' || val === true) { document.getElementById('a1').checked = true; document.getElementById('toshow').style.display = 'block'; document.getElementById('tohide').style.display = 'none'; } else if(val == 'off' || val === false) { document.getElementById('a2').checked = true; document.getElementById('toshow').style.display = 'none'; } } //this is my html <form action=" " method="post"> This is on <input id="a1" name="kind" type="radio" value="on" checked="checked" onclick="hidey(this.checked);" /><br /> This is off <input id="a2" name="kind" type="radio" value="on" checked="checked" onclick="hidey(this.checked);" /> Link to comment https://forums.phpfreaks.com/topic/241261-php-equivalent/ Share on other sites More sharing options...
Psycho Posted July 6, 2011 Share Posted July 6, 2011 Not sure what you really want. That code is manipulating the content in the user's browser. You can't do that with PHP. Aside from that, the structure of the code is valid for PHP. Link to comment https://forums.phpfreaks.com/topic/241261-php-equivalent/#findComment-1239281 Share on other sites More sharing options...
ManiacDan Posted July 6, 2011 Share Posted July 6, 2011 Javascript runs on the user's computer. PHP runs on your server. So no, there is no way to modify the contents of the user's computer with PHP, you have to completely reload the page. Link to comment https://forums.phpfreaks.com/topic/241261-php-equivalent/#findComment-1239282 Share on other sites More sharing options...
leijae Posted July 6, 2011 Author Share Posted July 6, 2011 ok thanks! Link to comment https://forums.phpfreaks.com/topic/241261-php-equivalent/#findComment-1239285 Share on other sites More sharing options...
Psycho Posted July 6, 2011 Share Posted July 6, 2011 What do you "hate" about that code. Is it not working the way you want it to? Link to comment https://forums.phpfreaks.com/topic/241261-php-equivalent/#findComment-1239287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.