I am trying to add the same ajax call that gets triggered when a checkbox is changed to a input field.
Here is the function that I also want to add when the value of the input field is changed:
$('#left input:checkbox').change(function() {
$('#formcontent').empty().html('<p style="margin-top:20px;text-align:center;font-family:verdana;font-size:14px;">Vent venligst, henter webhosts.</p><p style="margin-top:20px;margin-bottom:20px;text-align:center;"><img src="../images/ajax.gif" /></p>');
var form = $(this).closest('form');
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success:function(msg){
$('#formcontent').html(msg);
}
});
Here is my slider code. Which updates the input field:
$("#slider").slider({
value:'',
min: 0,
max: 5000,
step: 250,
slide: function(event, ui) {
if (ui.value == $(this).slider('option', 'max')) {
$(ui.handle).html('Ubegrænset');
$('#sliderValueplads').val('99999');
} else {
$(ui.handle).html(ui.value + ' MB');
$('#sliderValueplads').val(ui.value);
}
}
}).find('a').html($('#slider').slider('value'));
$('#sliderValueplads').val($('#slider').slider('value'));
Here is my html:
<div class="sliderdiv">
<div id="slider"></div>
<input type="text" style="display:none;" size="30" name="search[prisar_greater_than]" id="sliderValueplads">
</div>
I have tried to replace this line in the code:
$('#left input:checkbox').change(function() {
With this (not working):
$('#left input:checkbox', '#sliderdiv input').change(function() {
Update
I have tried clean up the code. The problem is that the callpage does not get triggerhed:
function callpage() {
$('#formcontent').empty().html('<p style="margin-top:20px;text-align:center;font-family:verdana;font-size:14px;">Vent venligst, henter webhosts.</p><p style="margin-top:20px;margin-bottom:20px;text-align:center;"><img src="../images/ajax.gif" /></p>');
var form = $(this).closest('form');
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success:function(msg){
$('#formcontent').html(msg);
}
$('#left input:checkbox').change(callpage);
And I get this error in firebug:
missing } after property list [Break ved denne fejl] $('#left input:checkbox').change(callpage)
The change event won’t fire on the text box if you change the value via the jQuery code, you’d need to do something like this in your code –
to trigger the change event.