Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in select

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
for quick solution please provide page source (html source)
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is happening for other options? And do you wish to submit the page only if the last option is selected?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aditi

Could you please try this code once
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please test the last code that I have posted?
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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





<% while(rst.next()) { %> <% }%>
Sec. No.Sec. NameLogin Id
<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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry This this


 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you goutam

but its not working

thank you
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@swastik i have already mentioned its not working this problem is same as i have faced before

thank you
 
Swastik Dey
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please share where the problem was?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic