| Author |
problem in select
|
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
Sorry bear for using java code on jsp page
on my jsp page i have a select in which on every option i want to remain on that age but for the last option i need to move to new page my code is this
while working on this page problem arises that on clicking last option it works ifine but for other options its not wrking please try it
let me know if there is anny solution to you
thank you
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
Hi,
for quick solution please provide page source (html source)
|
Thanks And Regards
Goutam Chowdhury (Scjp1.4 86%,SCWCD5 94%)
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
|
sorry to say but i cannot understand what you are saying actually i am working on jsp page so how to provide you html source code?
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
1.you can save the page (file-->save as) and share the .html file
2.right click --> "view page source " and copy the source and share
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
If you know it's a bad practice why do you still do it?
In any case,a View Source in the browser will show the generated HTML.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
Sorry once again Bear actually i am developing my project in struts so i am not developing my page in proper java pages thats the reason
i canot view the source code as its showing only frames code page
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
Hi,
Access your JSp page using fireFox browser ,then go to File-->Save Page As in the browser and save it in your local folder.In that folder you will get one folder and one .html file .You can share code of that html file
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
I have done asa you said but still its not giving me source code if possible for you please check in it only
thanks for your replies
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
What is happening for other options? And do you wish to submit the page only if the last option is selected?
|
Swastik
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
@swastik thanks for the reply
actually i want to sublit if my option is add new
for other options i need to remain at same page means when i click my 4th option it should be shown on select list not any other option
on clicking opther options as i am submitting same page so my 1st option is shown again & again
thank you
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
Hi Aditi,
I made a static html from code and named it as 1.html
I think its working fine....
Please check my code and confirm me you are getting expected result or not...
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
thank you goutam for your reply but still the problem exists as i have just explained before your reply
but thanks a lot
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
Aditi and Goutam, don't you think we need some sort of condition checking here, for e.g. call document.checkbox.submit() only if the last option is selected
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
1. What is your main jsp name ?is it "mapping.jsp"
2. Modify your Js function
Check whatever you are selected its showing in the alert message
3.If you select any option except last one which jsp page you are getting "mapping.jsp" or "map.jsp" or "adddiv.jsp"
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
Aditi
Could you please try this code once
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
thanks for the help swastik but still the same problem
whjenever i choose any other option the page will be refreshed & only shows me the 1st option
thank you
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
@goutam
if i select any other option then i will be on mapping.jsp on which on which i have written the above code
@swastik i have used th JS function as you said
like
i have cjhecked that at 0th position its only Add NEw option but my page donot show any change
thank you
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
Could you please test the last code that I have posted?
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
Please copy and paste this below code and let me know
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ page import="java.io.*,java.sql.* ,ams.database.*,javax.servlet.http.*,javax.servlet.*"%>
<html>
<head>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<script language="JavaScript">
function loadPage(list)
{
document.checkbox.SelectedIndex.value=list.options[list.selectedIndex].text;
location.href=list.options[list.selectedIndex].value;
document.checkbox.submit();
}
</script>
</head>
<body style=" background-color:#FFFFCC;">
<form name="checkedbox" method="post" action="map.jsp">
<%
try
{
Connection connection =new database().getConnection();
Statement s=null;
Statement st =null;
Statement st1=null;
ResultSet rs =null;
ResultSet rst=null;
ResultSet rst1=null;
s=connection.createStatement();
st = connection.createStatement();
String SelectedIndex=request.getParameter("SelectedIndex");
int id=0;
%>
<%
rs=st.executeQuery("SELECT * from ams_division;"); //"SELECT * from ams_division;"
rst=s.executeQuery("Select * from sec_code ;"); //"Select * from sec_code;"
%>
<input type="hidden" name="SelectedIndex"/>
<select name="combo" id="" onchange="loadPage(this.form.elements[0])" >
<% while(rs.next()){
if(SelectedIndex!=null && SelectedIndex.trim().eualIgnoreCase(ars.getString(2)))
{%>
<option value="mapping.jsp" SELECTED ><%=rs.getString(2) %></option>
<%}else{
%><option value="mapping.jsp" ><%=rs.getString(2) %></option>
<%}%>
<option value="adddiv.jsp">Add New</option>
</select>
Check the Sections of above selected division
| Sec. No. | Sec. Name | Login Id |
<% while(rst.next())
{
%>
|
<input type="checkbox" name="section" value="<%=rst.getString(2) %>"/> | <%=rst.getInt(1) %> | <%=rst.getString(2) %> | <%=rst.getString(3) %> |
<%
}%>
<%
}
catch(Exception e)
{
}
%>
<input type="submit" value="submit" />
</form>
</body>
</html>
|
 |
Goutam Chowdhury
Ranch Hand
Joined: Jan 20, 2009
Posts: 44
|
|
Sorry This this
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
thank you goutam
but its not working
thank you
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
@swastik i have already mentioned its not working this problem is same as i have faced before
thank you
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
I am not talking about that js function, I am talking about the complete code that I have pasted. Where location.href is called with a query string, and the query string is retrieved in the page. Did you try that one?
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
@swastik i have also posted for that that the code is not working
but now my purpose is solved
thanks to you all for the help
thank you so much
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
|
Could you please share where the problem was?
|
 |
Aditi agarwal
Ranch Hand
Joined: Feb 23, 2011
Posts: 225
|
|
actually i also cannot get the proper problem area i was trying different things & suddenly some changes made that
i can share the code so that it might help you
thank you
|
 |
 |
|
|
subject: problem in select
|
|
|