Solved

to call another jsp page

Posted on 2008-10-05
7
5,982 Views
Last Modified: 2013-11-11
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
Comment
Question by:priyapratheep
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:priyapratheep
ID: 22647278
ans pls
0
 
LVL 2

Expert Comment

by:priya_patil
ID: 22647516
a javascript method to call another jsp on On Click event is

use onclick="location.href='jsppage1.jsp'"
0
 

Author Comment

by:priyapratheep
ID: 22647522
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 2

Expert Comment

by:priya_patil
ID: 22647557
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
 
LVL 16

Expert Comment

by:sh0e
ID: 22647673
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
 

Author Comment

by:priyapratheep
ID: 22648414
hi sh0e:

how can u call this ....can u bit explin this
0
 
LVL 16

Accepted Solution

by:
sh0e earned 500 total points
ID: 22655616
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

Gigs: Get Your Project Delivered by an Expert

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

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

776 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