Solved

why my query string not append correctly ?

Posted on 2010-08-24
9
204 Views
Last Modified: 2012-05-10
Hi ,

I have one form i am submiting the form throw Javascript.

alert give correct only but in URL its show something wrong ?

I dont get where its wrong ?


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<fmt:setBundle basename="ApplicationResources"/>

<%@ taglib uri="/WEB-INF/displaytag-11.tld" prefix="display" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"

	pageEncoding="UTF-8"%>

	<%@ page import="java.util.ArrayList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/bioOrigin.css">

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/ddtabmenufiles/ddcolortabs.css" />

<script type="text/javascript" src="<%=request.getContextPath() %>/ddtabmenufiles/ddtabmenu.js"></script>

<script type="text/javascript">

//SYNTAX: ddtabmenu.definemenu("tab_menu_id", integer OR "auto")

ddtabmenu.definemenu("ddtabs4",2);



</script>



<title>¿¿¿¿¿¿¿¿</title>

<script type="text/javascript">



function shohinSearch()

{

	var shohinCode=document.shohinCodeSearch.shohinName.value;

	alert(shohinCode);

	document.shohinCodeSearch.action='<%=request.getContextPath() %>/shohinSearch.do?action=searchButton&shohinCode='+shohinCode;

	alert(document.shohinCodeSearch.action);



	document.shohinCodeSearch.submit();

	

}





</script>

<body>





<form name="shohinCodeSearch" id="shohinCodeSearch">



           <table align="left" width="60%" >

            <table>

				<tr>

					<td class="bFF"> <bean:message key="label.maualInput.allSearchScreen" />  </td>

				    <td></td>

				     <td></td>

				</tr>

			</table>

			<table>	

					<tr>

					<td class="tdLableColor" width="20%"> <bean:message key="label.manualInput.shohinSearch.shohinKana" />  </td>

				    <td width="30%" > <input type="text" name="shohinName" id="shohinName"> </td>

				    <td width="20%" align="right"><input type="button" name="btnSubmitProceed" value="<bean:message key="button.lotshohin.search"/>" onclick="shohinSearch();">  </td>

				</tr>

			</table>

           </table>     

      <br></br>

       <c:if test="<%= request.getAttribute("shohinCodeList") != null &&    

	((ArrayList)request.getAttribute("shohinCodeList")).size() > 0 %>" >

      <% int i =0; %>

       <display:table  name="shohinCodeList" pagesize="20"  align="center" cellpadding="5" class="data" requestURI="/shohinSearch.do"  id="processTable" >

              <display:column    title="¿¿¿¿¿" align="center">

               <a href="javascript:gotoCheck('<%=i %>','${processTable.shohinCode1}')" >${processTable.shohinCode1 }</a>

         

               </display:column>

            <display:column property="shohinName" title="¿¿¿" align="center" />

            

                        <%=i++ %>

       </display:table>

 </c:if>

 



</form>

</body>

</html>

Open in new window

0
Comment
  • 4
  • 4
9 Comments
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33514511
Screen shot !
error1.JPG
error2.JPG
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33514530
I am passing only action=searchButton&shohinCode='+shohinCode
but
it says http://localhost:8082/Bio-Origin/shohinSearch.do?shohinName=sathish
why this problem arise ?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 33514886
because you're using form_name.submit()
so you replace the value you're thinking you set.

use instead : location.href = '<%=request.getContextPath() %>/shohinSearch.do?action=searchButton&shohinCode='+shohinCode;
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33514942

Replace :
	document.shohinCodeSearch.action='<%=request.getContextPath() %>/shohinSearch.do?action=searchButton&shohinCode='+shohinCode;
	document.shohinCodeSearch.submit();
By :
        location.href = '<%=request.getContextPath() %>/shohinSearch.do?action=searchButton&shohinCode=' + shohinCode;

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33514984
ya its gr8 thanks.
 
But i want know why document.formName.submit() is not working ??
for other form its working gd only ? for this form only its not working ? why ?
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 400 total points
ID: 33515413
form.submit() create/build itself a request with elements of the form content
0
 
LVL 17

Assisted Solution

by:jrm213jrm213
jrm213jrm213 earned 100 total points
ID: 33515426
Hi,

Action is required attribute of the form tag. While not having it there some browsers may assume it means itself, however I think not having anything in it may be causing javascript to not be able to set it.

change
<form name="shohinCodeSearch" id="shohinCodeSearch">

to

<form name="shohinCodeSearch" id="shohinCodeSearch" action="#">

and see if that resolves the issue.
0
 
LVL 20

Author Closing Comment

by:Sathish David Kumar N
ID: 33534868
Thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33535519
You're welcome! Thanks for the points!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now