Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
JSP
How to retain selected value from dropdown list in same jsp page
sudarshan jadhav
Ranch Hand
Posts: 42
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
:banghead:
In addoperator.jsp page station name dropdown value get retain on same jsp page
<script language="javascript" type="text/javascript"> function funct() { var sname=document.form.sname.value; window.location.replace("AddOperator.jsp?sname="+sname); } </script> addoperator.jsp <form name="form" method="get" action="AddOperator"> <br><br> <table cellpadding="5" cellspacing="5" width="400px" height="30px" align="center"> <tr align="center" style="background-color:#B0B0B0;font-weight:bold;color:black;"> <td align="center" style="border: 1px solid appworkspace; margin: 0; padding: 1px;font-size:103%;">Add Field Officer </td> </tr> <tr> <td> <center> <% HttpSession sess = request.getSession(); String cid=sess.getAttribute("cid").toString(); sess.setAttribute("cid",cid); Connection con = Dbconnect.getConnectionObject(); %> <% String sname = request.getParameter("sname"); %> <table class="main" width="200px" align="center" style="border:0px solid #000000;"> <tr> <td align="center"> <select id='sname' name="sname" onchange="funct(this.value)" style="width: 200px " > <option value="" >Select Station Name</option> <% try { PreparedStatement psmnt = con.prepareStatement("select sname from station "); ResultSet rs = psmnt.executeQuery(); while(rs.next()){ String name = rs.getString("sname"); %><option value="<%= name %>" > <% out.println(name); %> </option> <% } %> </select> </td> <tr> </table> <%String option=request.getParameter("sname"); if(option==null){ } else { %> <br> <table class="main" width="350px" align="center" style="border:0px solid #000000;"> <tr> <td align="left" style="width: 195px;">Station Name </td> <td align="left"><%=option%></td> <% } %> <% rs.close(); } catch(Exception e) { out.println(e); } %> </tr> <% String name1=request.getParameter("sname"); Statement st1 = FetchDb.createStatement(con); ResultSet rs1=null; rs1=st1.executeQuery("Select * from station where sname='"+name1+"'"); String sid=""; String saddress=""; while(rs1.next()) { sid=rs1.getString("sid"); saddress=rs1.getString("saddress"); %> <input type="hidden" style="width: 195px;" value="<%=sid%>" name="sid"> <tr> <td align="left" style="width: 195px;">Station Address</td> <td align="left" style="width: 195px; background-color: #DCDCDC"><%=saddress%></td> <input type="hidden" value="<%=saddress%>" name="saddress"> </tr> <tr> <td align="left" style="width: 195px;"> Field Officer Name</td> <td align="right"><input type='text' style="width: 195px;" name='pname' id='pname' maxlength="44" onkeyup="check(this.value);"> </td> </tr> <tr> <td align="left" style="width: 195px;"> Designation</td> <td align="right"><input type='text' style="width: 195px;" name='pdesign' id='pdesign' maxlength="44"></td> </tr> <tr> <td align="left" style="width: 195px;"> Mobile Number</td> <td><input type="text" style="width: 195px;" name='pphno' id='pphno' maxlength="10" onkeypress="return isNumberKey(event)" onkeyup="check1(this.value);"> </td> </tr> <tr> <td align="left" style="width: 195px;">Email ID</td> <td align="right"><input type='text' style="width: 195px;" name='pemail' id='pemail' maxlength="44"></td> </tr> </table> </center> <br> <center> <input type="submit" name="Submit" value="Submit" onmouseover="style.backgroundColor='#B30000', style.color='white', style.fontWeight='bold',style.fontWeight='bold'" onmouseout="style.backgroundColor='#B0B0B0', style.fontWeight='bold', style.color='black', style.fontWeight='normal'" onclick='return Validate();'> </center> <% } rs1.close(); st1.close(); con.close(); sess.setAttribute("sname", sname); %> <br> </td> </tr> </table> </center> </form> </body> </html>
RatiKanta pal
Ranch Hand
Posts: 88
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
What error is comming?have you checked your javascript function is called or not?
sudarshan jadhav
Ranch Hand
Posts: 42
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you for your reply,
In myjsp page javascript is work but the first dropdown value is not stable .
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question on jQuery ajax functionality & troubleshooting called bean in JSF page
Doubts in jsp
how the response from ajax in jsp page get refresh when two dropdown fetch from database dependent
exception
wrong jar reference
Value not pass correctly
More...