开发者

radiobutton passing value without reloading page

is there a way of passing the value without reloading the page?

The value from the checked radiobutton is then passed to the session variable

$_SESSION['user']['moms'] = $_POST['radio_button'];


<form name="f1" action="" method="post">
<label for="exkl">
<input type="radio" id="exkl" name="radio_button" onClick="this.form.submit();"  value="1"<?php if(($_POST['radio_button'] == 1) || ($_POST['radio_button'] == "")) {  print ' checked="checked"'; } ?> /> Exkl开发者_JS百科. moms</label>
<label for="inkl">
<input type="radio" id="inkl" name="radio_button" onClick="this.form.submit();" value="2"<?php if($_POST['radio_button'] == 2) { print ' checked="checked"'; } ?> /> 
Inkl. moms</label>
</form>

thanks linda


You can do it via AJAX request which will call scripts on the server. The script will set the session variable. And the AJAX request can be executed on onchange javascript event.

Look on jQuery for example.


Dont submit the form with onclick of the radio button, instead call a function, that checks whether the particular radio button is checked, and sends an ajax request to a php page, to store the radio button value in the session.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜