Tuesday, 20 August 2013

Javascript Function not working in Ajax

Javascript Function not working in Ajax

Ok so I've got a drop down menu, and on selection of an item in the list
there is a value set to it and therefore it displays a certain div. for
some reason this is no longer working now that i have opened the
containing page within a div. I think its something to do with the
document. in the JS. Can anyone help?
Heres the JS:
<script language="javascript">
function dispNext(){
if(document.getElementById("srv_q1").value == "2"){
document.getElementById("q2").style.display="block"
}
if(document.getElementById("srv_q1").value == "3" ||
document.getElementById("srv_q1").value == "1"){
document.getElementById("q2").style.display="none
}
}
</script>
<select id="srv_q1" name="srv_q1" onchange="dispNext();">
<option value="0">
-- Please choose an option from the list below --
</option>
<option value="1">
The service has been completed
</option>
<option value="2">
The service has not yet been completed
</option>
<option value="3">
The service was not completed
</option>
</select>
<div id="q2" style="display: none;">
<strong>My Service has not yet been carried out in full, please
remind
me again in:</strong><br>
<input checked="checked" name="days" type="radio" value="7">&nbsp;7
days<br>
<input name="days" type="radio" value="14">&nbsp;14 days<br>
<input name="days" type="radio" value="28">&nbsp;28 days<br>
</div>
<div id="feedbackform"></div><script type="text/javascript">
jQuery().ready(function(){
/* function */
jQuery('#srv_q1').change(function(){
if( (jQuery(this).val() == '1') || (jQuery(this).val() == '3')
) {
jQuery('#feedbackform').html("{feedback_form}");
} else {
jQuery('#feedbackform').empty();
}
});
});
</script>

No comments:

Post a Comment