Is it possible to call a php function when an html radio button is selected?
I’m working on building a donate page for a small non-profit school that will have three options: Donate, Pay Tuition, or Make a Monthly Donation.
I would like for the choice of the radio button to load the rest of the webpage based on their selection. If possible, I’d like to do this without using javascript (if user disabled) or iframes.
Currently, if I’m using javascript, it works with this code:
<html>
<head>
<script type="text/javascript">
function go (url) {
parent.frame_name.location = url;
}
</script>
</head>
<body>
I would like to:
<br />
<input type="radio" name="type" value="donate" onclick="go ('makedonate.php')">Make a Donation
<input type="radio" name="type" value="tuition" onclick="go ('paytuition.php')">Pay My Child's Tuition
<input type="radio" name="type" value="monthly" onclick="go ('makemonthly.php')">Become a Monthly Sponsor
<iframe name="frame_name" frameborder="0" width="600" height="300"></iframe>
</body>
</html>
Is it possible? Any thoughts?
Put it in a HTML
<form>element and add a<input type="submit">button. Let the form’sactionpoint to a single PHP page. In the PHP function behind the PHP page, determine the radio button pressed based on the parameter name and/or value and finally display the rest of page conditionally based on the selected radio button usingif-elseorswitchstatement.