main page index.html
<!doctype html> <html> <head> <title>insert title here</title> <script type="text/javascript" > var request; function sendarrr() { var v = document.getelementbyid('x').value; // var url="run.jsp?q="+string1; if(window.xmlhttprequest){ request=new xmlhttprequest(); } else if(window.activexobject){ request=new activexobject("microsoft.xmlhttp"); } try{ request.onreadystatechange=getinfo; request.open("get","run.jsp?q="+v,true); request.send(); }catch(e){alert("unable connect server");} } function getinfo(){ if(request.readystate==4){ var val=request.responsetext; document.getelementbyid('dsp').innerhtml=val; } } </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script> <script> $(document).ready(function(){ alert("master"); }; </script> </head> <body> <form> enter id:<input type="text" id="x" name="tt"/> <input type="button" name="bt" onclick="sendarrr()" value="click"/> </form> <span id="dsp"></span> </body> </html> page loaded in ajax run.jsp <%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ page import="java.sql.*" %> <% class.forname("com.mysql.jdbc.driver"); %> </script> <html> <head> <title>data</title> <script> $(document).on('click', 'a', function(event){ alert("slave"); }); </script> </head> <body> <% string s=request.getparameter("q"); system.out.println("hi"); if(s==null || s.trim().equals("")){ out.print("please enter id"); }else{ // int id=integer.parseint(s); system.out.print(s); string url = "jdbc:mysql://localhost:3306/fees"; string user = "root"; string passswd = "password"; system.out.println("how you"); connection connection = drivermanager.getconnection(url,user,passswd); statement statement = connection.createstatement(); string sql="select * fee1 id=?"; preparedstatement ps=connection.preparestatement(sql); ps.setstring(1,s); resultset rs=ps.executequery(); %> <input type="radio" id="rd"> <input type="text" id="fr"> <table border="1"> <tr> <th>id</th> <th>name</th> <th>fee</th> <th>course</th> <th>occupation</th> <th>balance</th> <th>date</th> </tr> <% while(rs.next()){ { %> <tr> <td> <%= rs.getstring(5) %> </td> <td> <%= rs.getstring(1) %> </td> <td> <%= rs.getstring(2) %> </td> <td > <%= rs.getstring(3) %> </td> <td > <%= rs.getstring(4) %> </td> <td > <%= rs.getstring(6) %> </td> <td> <%= rs.getstring(7) %> </td> </tr> <% } %> </table> <% } connection.close();} %> </body> </html> i want hide radio , text fields in second page.when user enters id , presses submit second page loads ajax .on second page want hide radio , text input fields. tried jquery .on , .live can't work . please .thnx
try : put code inside $(document).ready(.. ensure dom ready , call .hide() on radio , text box.
$(document).ready(function(){ $('#rd').hide(); $('#fr').hide(); }); edit: loading page on ajax call hide radio button , text on callback function of ajax i.e. getinfo
function getinfo(){ if(request.readystate==4){ var val=request.responsetext; document.getelementbyid('dsp').innerhtml=val; document.getelementbyid('rd').style.display = 'none'; document.getelementbyid('fr').style.display = 'none'; } }
Comments
Post a Comment