Hi. I need help with this section of code.
What I want to do is; when I click (for example) a radio button 1, that button value display on the browser. I have a three radio buttons.
Here's my ajax query:
function updatepayment(this.value)()
var ajaxResponse = new Object();
$(document).ready(function () {
$('.rmr').click(function () {
var rbVal = $(this).val();
var myContent;
if (ajaxResponse[rbVal]) { //in cache
myContent = ajaxResponse[rbVal];
$("#contentcontainer").html(myContent);
}
else { // not in cache
var urlForAjaxCall = "include/function.php" + rbVal + ".html";
$.post(urlForAjaxCall, function (myContent) {
ajaxResponse[rbVal] = myContent;
$("#contentcontainer").html(myContent);
});
}
});
});
var ajaxResponse = new Object();
$(document).ready(function(){
$('.rmr').click(function (){ var rbVal = $(this).val(); var myContent; if (ajaxResponse[rbVal]) { //in cache $("#contentcontainer").html( ajaxResponse[rbVal] ); } else { // not in cache var urlForAjaxCall = "include/function.php" + rbVal + ".html"; $("#contentcontainer").load(urlForAjaxCall, function (myContent) { //Extra processing can be done here, like your cache ajaxResponse[rbVal] = myContent; }); }
});
});
EDIT: After seeing your comments on your OP You are trying to select the radio buttons by class name "rmr" but do not have it set on the tags you need:
<input class="rmr" type="radio" name="rmr" id="payment1" value="3" onclick="updatepayment(this.value)" /> <br>
<input class="rmr" type="radio" name="rmr" id="payment2" value="5.5" onclick="updatepayment(this.value)" /><br>
<input class="rmr" type="radio" name="rmr" id="payment4" value="10" onclick="updatepayment(this.value)" /><br>
or you could use
$("input[name=rmr]")
to select them by their input name attribute
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.