Jump to content

cfajardo

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by cfajardo

  1. It's working now, Thank you!! Regards
  2. What I don't understand is why id doesn't work on the same the example http://www.w3schools.com/ajax/ajax_database.asp is written? Regards,
  3. Thank you for your response, So you mean that the value should be: <select name="carrera" onchange="showSubject(this.options[this.selectedIndex].value)" >? For the name of the pages, I renamed it, thank you, actually, the querystring is getting an id value, numeric value. Regards,
  4. Hi, I need to fill a drop-down box from another drop-down box in an ASP using AJAX, I was following the AJAX Database example, but I don't get the data, so don't know what am I doing wrong, could anyone please help me trying to figure out what's wrong or if you have an example of how to fill a drop-down box once you change the value of another drop-down box? here is my code: AJAX.JS function showSubject(str){var xmlhttp;if (str=="") { document.getElementById("materias").innerHTML=""; return; }if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("materias").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","materiaslista.asp?q="+str,true);xmlhttp.send();} MATERIASPAGE.ASP<% response.expires=-1 Set base=Server.CreateObject("ADODB.Connection")base.ConnectionString = "DSN=acc"base.Open strSql="Select * from tblMaterias where Carrera="strSql=strSql & "'" & request.querystring("q") & "'" set rsMat=Server.CreateObject("ADODB.recordset")rsMat.Open strSql,base response.write("<table>") do until rstMat.eof for each x in rstMat.Fieldsresponse.write("<tr><td><b>" & x.name & "</b></td>") response.write("<td>" & x.value & "</td></tr>") next rstMat.movenext loop response.write("</table>") %> STUDENTS.ASP I have: <script type="text/javascript" src="ajax.js"></script> <form method="post" action="save_data.asp?ac=1" name="Form1"><tr><td class="style5"><span lang="es-pa"><strong>Carrera</strong></span>:</td> <td class="style5"> <select name="carrera" onchange="showSubject(this.value)" > <option value="">Seleccione una carrera!</option> <%while not rstCar.eof%><option value="<%=rstCar.Fields("id")%>"><%=rstCar.Fields("carrera")%></option><%rstCar.MoveNextwend%></select></td></tr><tr> <td class="style5"><strong>Materias:</strong></td> <td class="style5"> <div id="materias">TEXTO</div></td></tr></form> Thanks
×
×
  • Create New...