Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5993
  • Last Modified:

to call another jsp page

u have a form where it has two buttons when i click one button i have to call jsppage1 with parameter emp_name,when i click second button i have to call jsppage1 with another parameter

can anybody help[ this

i attach my program

<input type="Submit" name="Submit" value="Download By ManufacturerName">
                              <input type="button" name="ByRegion" value="Download By Region" onClick="??????">

i want to do my program the same this as submit button...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Down Load Future Electronics Data</title>
 
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
	function lookupName(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("fut_ele_ByManName.jsp", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
    function lookup1(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("fut_ele_ByRegoin.jsp", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
 
	function fillName(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
    
      function fill1(thisValue) {
		$('#inputString1').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
    
function message(inputString)
{
  
		
			$.post("futer_excel_byRegionMain.jsp", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					alert(data);
				}
			);
		
 
 
 
}
</script>
	<LINK REL=stylesheet HREF="ssl.css" TYPE="text/css">
		<style type="text/css">
  <!--
    body {
    margin-left: 20px;
    margin-top: 20px;
    }
  -->
</style>
<style type="text/css">
	body {
		font-family: Helvetica;
		font-size: 11px;
		color: #000;
	}
	
	h3 {
		margin: 0px;
		padding: 0px;	
	}
 
	.suggestionsBox {
		position: relative;
		left: 30px;
		margin: 10px 0px 0px 0px;
		width: 200px;
		background-color: #3574EC7;
		-moz-border-radius: 7px;
		-webkit-border-radius: 7px;
		border: 2px solid #000;	
		color: #fff;
	}
	.suggestionsBox1 {
		position: relative;
		left: 200px;
		margin: 20px 0px 0px 0px;
		width: 700px;
		background-color: #3574EC7;
		-moz-border-radius: 7px;
		-webkit-border-radius: 7px;
		border: 2px solid #000;	
		color: #fff;
	}
	
	.suggestionList {
		margin: 0px;
		padding: 0px;
	}
	
	.suggestionList li {
		
		margin: 0px 0px 3px 0px;
		padding: 3px;
		cursor: pointer;
	}
	
	.suggestionList li:hover {
		background-color: #659CD8;
	}
</style>
 
</head>
 
<body>
 
 
		<H1>
			Download Data
		</H1>
		<BR>
 
 
	<div>
            <table width="" border="0" cellpadding="1" cellspacing="0" bgcolor="#4682b4">
		<tr>
		<td>
 
		<form >
 
		<table width="100%" border="0" cellpadding="4" cellspacing="1">
							<tr class="data1">
								<td>
									Enter the Manufacturer name:
								</td>
								<td>
									:
								</td>
 
<td>
 
 
			<div>
				
				<br />
				<input type="text" size="30" value="" name="emp_name" id="inputString" onkeyup="lookupName(this.value);" onblur="fill();" />
			</div>
			
			<div class="suggestionsBox" id="suggestions" style="display: none;">
				<img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
				<div class="suggestionList" id="autoSuggestionsList">
					&nbsp;
				</div>
			</div>
			</td>
			</tr>
			<tr class="data2">
			<td>
			Region
			</td>
			<td>
			:
			</td>
			<td>
 
<div>
				
				<br />
				<input type="text" size="30" value="" name="emp_id" id="inputString1" onkeyup="lookup1(this.value);" onblur="fill1();" />
			</div>
			
			<div class="suggestionsBox1" id="suggestions" style="display: none;">
				<img src="upArrow.png" style="position: relative; top: -999px; left: 30px;" alt="upArrow" />
				<div class="suggestionList" id="autoSuggestionsList">
					&nbsp;
				</div>
			</div>
 
 
</td>
							</tr>
								</table>
				</td>
			</tr>
			<tr>
				<td align="center">
					<input type="Submit" name="Submit" value="Download By ManufacturerName">
					<input type="button" name="ByRegion" value="Download By Region" onClick="??????">
 
				</td>
			</tr>
		</table>
 
		</form>
	</div>
 
</body>
</html>

Open in new window

0
priyapratheep
Asked:
priyapratheep
  • 3
  • 2
  • 2
1 Solution
 
priyapratheepAuthor Commented:
ans pls
0
 
priya_patilCommented:
a javascript method to call another jsp on On Click event is

use onclick="location.href='jsppage1.jsp'"
0
 
priyapratheepAuthor Commented:
i want to pass parameter also

i want to pass the value of the text box

<input type="text" size="30" value="" name="emp_id" id="inputString1" onkeyup="lookup1(this.value);" onblur="fill1();" />
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
priya_patilCommented:
give a name to your form tag
i.e. <form name="form1">

add javascript function

<script language="javascript">
function calljsp()
{

      //alert(" ********* "+document.form1.emp_id.value);
      val=      document.form1.emp_id.value;
      location.href="jsppage1.jsp?param="+val;

}
</script>

and call function
onclick= "javascript:calljsp()"

if you write your code inside <% %>(i.e. scriplets)
than you can directly get the parameter using
onlick="javascript:calljsp(this.form.emp_id.value)"
0
 
sh0eCommented:
Missed a bracket on line 56 in function "message()":
                        $.post("futer_excel_byRegionMain.jsp", {queryString: ""+inputString+""}, function(data){
                                if(data.length >0) {
                                        alert(data);
                                }
                        }); //<--- missing bracket


//add this jQuery code to post data
<script type="text/javascript">
;$(function(){
	$("form").submit(function(){
		message($("input[name='emp_name']").val());
		return false;
	});
	
	$("input[name='ByRegion']").click(function(){
		message($("input[name='emp_id']").val());
		return false;
	});
});
</script>

Open in new window

0
 
priyapratheepAuthor Commented:
hi sh0e:

how can u call this ....can u bit explin this
0
 
sh0eCommented:
That code just works.  Copy/paste it into your web page.
It binds message() to form.submit and ByRegion.click

You need to fix your function message()
It is missing a bracket on line 56
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now