...

View Full Version : Replace content instead of show/hide



sketchgal
06-12-2011, 08:53 PM
Can anyone tell me how I can change the code below so that instead of all the fade in fade out stuff the function will actually replace whatever is inside a div called Myholder with the response this script pulls in?

Here's the code I need to change.

<script type="text/javascript">
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$.get("func.php", {
func: "drop_1",
drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
});
return false;
});
});

function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>

drop_1 is the name of a drop down which when changed runs this script which brings back a second dropdown with data relating to the first one.

If I need to post more info to get some help with this please let me know.

Thanks in advance.

AndrewGSW
06-12-2011, 10:02 PM
Assuming 'Myholder' is the id for the div

function finishAjax(id, response) {

$('#Myholder').html(unescape(response));

}
You could strip out other stuff you don't need (including the id parameter).

sketchgal
06-12-2011, 10:25 PM
Thanks so much for the help with that it works perfectly now. Don't suppose you could help me with a checkbox issue I'm having aswel could you?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum