Solved

why my query string not append correctly ?

Posted on 2010-08-24
9
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.
Suggested Courses

623 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