function add_tag( theform ) { // get the form's input var resource = theform.resource.value; var tag = theform.tag.value; var username = theform.username.value; // process the input post_tag ( resource, tag, username ); // cleanup and done expand( 'd' + resource ); return false; } function post_tag( resource, tag, username ) { // use the input to create a GET request var url = './index.cgi?cmd=post_tag&resource=' + resource + '&tag=' + tag + '&username=' + username; // create a xmlRequest var xmlRequest; if ( window.XMLHttpRequest ) { xmlRequest = new XMLHttpRequest(); } else if ( window.ActiveXObject ) { xmlRequest = new ActiveXObject( "Microsoft.XMLHTTP" ); } // sanity check if ( !xmlRequest ) { alert( 'Giving up: Cannot create an XMLHTTP instance' ); return false; } // give the xmlRequest some characteristics and send it off xmlRequest.open( 'GET', url, true ); xmlRequest.send( null ); xmlRequest.onreadystatechange = function() { if ( xmlRequest.readyState == 4 ) { var xmldoc = xmlRequest.responseXML; var root_node = xmldoc.getElementsByTagName( 'root' ).item( 0 ); alert ( root_node.firstChild.data ); } } } function expand( id ) { var details = document.getElementById( id ); details.style.display = ( details.style.display == 'block' ) ? 'none' : 'block'; }