Question : why my query string not append correctly ?

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 ?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
<%@ 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>

Answer : why my query string not append correctly ?

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;
Random Solutions  
 
programming4us programming4us