Home Blog CV Projects Patterns Notes Book Colophon Search

YUI for AJAX Replace

14 Aug, 2007

Here's the same example as before but implemented using YUI rather than scriptaculous:

${h.select(
    "TopicSet-1.TopicID",
    option_tags=topic_options,
    onchange="callAJAX('%s','diseases-select'); return false;"%(
        h.url_for(controller="newstudy",
            action="disease_dropdown_fragment"),
    )
)}
<script type="text/javascript">
//<![CDATA[
function callAJAX(sUrl, replace){
    var callback = {
    success: function(o) {
        YAHOO.util.Dom.get(replace).innerHTML = o.responseText;
     },
    failure: function(o) {
        alert("Failed to retrieve required information.");
    }
}
sUrl = sUrl +'?TopicSet-1.TopicID='
sUrl = sURL+YAHOO.util.Dom.get('TopicSet-1.TopicID').value;
var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl,
       callback, null);
}
//]]>
</script>

Copyright James Gardner 1996-2020 All Rights Reserved. Admin.