Solved

why my query string not append correctly ?

Posted on 2010-08-24
9
203 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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 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:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

9 Experts available now in Live!

Get 1:1 Help Now