Solved

why my query string not append correctly ?

Posted on 2010-08-24
9
206 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lazy load not working with masonry js 1 20
Using javascript confirmation for a delete in mysql 5 31
where is team.js? 3 26
key press alert 2 17
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

777 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