javascript - Reprinting Form input in html -
so designing website myself, takes user input user through form, searches same in database , , returns expected output.
below shown html code same.
<%@ page import="java.sql.*"%> <%@ include file="dbconn.jsp" %> <%@ page import = "java.sql.*"%> <% string id,time,result,obj; statement stmt,stmt2; resultset rs; string sql=""; string k="key"; string w="wallet"; string p="pen"; string a="atm"; id=""; time=""; result=""; string save=request.getparameter("bsave"); string delete=request.getparameter("bdelete"); string search=request.getparameter("bsearch"); stmt = con.createstatement(); if (search!=null) { obj=request.getparameter("id"); if(obj.equals(k)) { id="05447646"; } else if(obj.equals(w)) { id="05447647"; } else if(obj.equals(p)) { id="05447649"; } else if(obj.equals(a)) { id="05447650"; } rs=stmt.executequery("select * tablename1 id='"+ id +"'"); while(rs.next()) { id=rs.getstring("id"); time=rs.getstring("time"); } } %> <!doctype html> <html> <head> <title>intelli-track search interface</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <link href="1.css" rel="stylesheet" /> <style type="text/css"> #head1{ position: absolute; width: 100%; top: 126px; visibility: visible; left: 4px; } #tab1 { position: absolute; width: 780px; height: 408px; z-index: 1; left: 1px; top: 272px; right: auto; } #apdiv1 { position: absolute; width: 403px; height: 408px; z-index: 1; left: auto; top: 200px; right: -1px; } .center1 { text-align: center; } #apdiv1 .indent-1 { text-align: center; font-size: 44px; } #apdiv1 p { text-align: center; } </style> <script src="js/jquery-1.8.3.min.js"></script> <script src="css/5grid/init.js?use=mobile,desktop,1000px"></script> <script src="js/init.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#login_frm").submit(function(){ //remove previous class , add new "myinfo" class $("#msgbox").removeclass().addclass('myinfo').text('validating login ').fadein(2000); this.timer = settimeout(function () { $.ajax({ url: 'check.jsp', data: 'un='+ $('#login_id').val() +'&pw=' + $('#password').val(), type: 'post', success: function(msg){ if(msg != 'error') // message sent, check , redirect { // , direct success page $("#msgbox").html('login verified, logging in.....').addclass('myinfo').fadeto(900,1, function() { //redirect secure page document.location='login.jsp?user='+msg; }); } else { $("#msgbox").fadeto(200,0.1,function() //start fading messagebox { //add message , change class of box , start fading $(this).html('sorry, wrong combination of username , password.').removeclass().addclass('myerror').fadeto(900,1); }); } } }); }, 200); return false; }); }); </script> <noscript> <link rel="stylesheet" href="css/5grid/core.css" /> <link rel="stylesheet" href="css/5grid/core-desktop.css" /> <link rel="stylesheet" href="css/5grid/core-1200px.css" /> <link rel="stylesheet" href="css/5grid/core-noscript.css" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/reset.css" /> <link rel="stylesheet" href="css/structure.css" /> <link rel="stylesheet" href="css/style-desktop.css" /> </noscript> <!--[if lte ie 9]><link rel="stylesheet" href="css/ie9.css" /><![endif]--> <!--[if lte ie 8]><link rel="stylesheet" href="css/ie8.css" /><![endif]--> <!--[if lte ie 7]><link rel="stylesheet" href="css/ie7.css" /><![endif]--> </head> <body> <form name="form1" method="post" action=""> </form> <nav id="nav"> <ul> <li><a href="index.html">home</a></li> <li><a href="intel.html">about intelli-track</a></li> <li><a href="signout.jsp">logout</a></li> <li><a href="#contact">contact</a></li> </ul> </nav> <div class="image-centered" id="head1"> <header> <h1 align="center">welcome <strong>intelli-track</strong> search interface</h1><hr> </header> </div> <div id="tab1"> <table align="center" width="800" style="border:10px solid #d2d2d2"> <tr><th align="center"><h3><u>object</u></h3></th><th width="234" align="center"><h3><u>tag-id</u></h3></th> <th width="394" align="center"><h3><u>last accessed date , time</u></h3></th></tr> <tr></tr> <tr><td align="center"><script type="text/javascript"> </script> </td><td align="center"><%=id%></td> <td align="center"><%=time%></td> </tr> </table> </div> <div id="apdiv1"> <p> </p> <h3 class="indent-1"> <span class="center1">object finder</span> </h3> <form name="form2" width=70% method="post" action=""> <p> <label for="id">enter object searched:</label> </p> <p> <input type="text" name="id" id="idd"> </p> <p> <input name="bsearch" type="submit" class="button-big" value="search"> </p> </form> <p> </p> </div> </body> </html> this page looks :

so page , when user enter value in form ( valid values pen,key,atm,wallet), retrieves last time of pen access , tag_id, stored in database. while can retrieve these 2 values. not know how print name of object in first column "object", again should print valid object (like pen, wallet, atm, key)
what should put here in part of code, achieve same. :
<table align="center" width="800" style="border:10px solid #d2d2d2"> <tr><th align="center"><h3><u>object</u></h3></th><th width="234" align="center"><h3><u>tag-id</u></h3></th> <th width="394" align="center"><h3><u>last accessed date , time</u></h3></th></tr> <tr></tr> <tr><td align="center"><script type="text/javascript"> goes here ..??? </script> </td><td align="center"><%=id%></td> <td align="center"><%=time%></td> </tr> </table> i have tried using document.getelementbyid doesn't works...!! , yes there's no validation in too..!!
simply put want display text entered in text-box object finder if not wrong?
if yes, retrieving in jsp string obj=request.getparameter("id"); use <%= obj %> wherever want display value, like:
<tr> <td align="center"> <%= obj %> </td> ...
Comments
Post a Comment