Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

why my query string not append correctly ?

Posted on 2010-08-24
9
Medium Priority
?
212 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 1600 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the 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 1600 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 400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

715 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