Click to See Complete Forum and Search --> : java script parameters to be used in jsp????


majorpain03
05-09-2003, 01:34 AM
hi please help me with my problem... i am new to this...

can a java script call a jsp?

i have a script like this...

function getTargetTable(pCluster, pYear){
// i want the pCluster and pYear parameter to be stored
// in strFilter so that i can use it when a set the property
// of the bean...
<% String strFilter = pCluster+","+pYear; %>
<jsp:setProperty name="targetSettingBean" property="targetTable" value="<%= strWhere %>" />
}

is that possible? if not can u give me other alternatives?

thank you very much in advance

:confused:
ronnie

A1ien51
05-09-2003, 01:48 AM
I am not sure if this is what you are after......

basic idea to change a variable/paramter in an Applet/Object

you can use the param tag inside of an applet/object tag

<applet code="Hello.class" width.....blah... id="TheApplet">
<parm name="display" value="This is some text">
</applet>

THe basic idea with the javascript would be

<script>
function displayitem(){
var applet = document.getElementById("AppletID");
applet.AppletVariable = "Your String";
applet.repaint();
}

majorpain03
05-09-2003, 02:04 AM
thank you for your help, but i'm not using an applet... sorry if i can't explain clearly what i want to do but here is the whole code of my jsp...

basically what i want to do is to call the javascript passing the two parameters, and the parameters which i pass will be used to set a property of the bean(jsp)... how can i do it?

<%@ page contentType="text/html;charset=WINDOWS-1252"%>

<jsp:useBean id="targetSettingBean" class="ams.inquiry.TargetSettingBean" />

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=WINDOWS-1252">
<title>Target Setting</title>
<%@ include file="header.jsp" %>

-- and here is my problem --
<SCRIPT LANGUAGE="JavaScript">
function getTable(pCluster,pTYear){
<%String strWhere = "01,2002";%>
<jsp:setProperty name="targetSettingBean" property="targetTable" value="<%= strWhere %>" />
}
</SCRIPT>


</HEAD>

<BODY topmargin="0" leftmargin="0">
<TABLE border="0" width="100%" cellspacing="0" cellpadding="10" height="100%">
<TR>
<TD rowspan="4" width="20%" class="sideBar" valign="top" height="100%">
<jsp:include page="sidebar.jsp" />
</TD>
<TD>
<TR>
<TD>
<form method="GET" name="pricesform" action="controller">
<input type="hidden" name="action" value="targetSetting">
<table width="100%">
<tr>
<td width="5%" class="labelType">
Cluster
</td>
<td width="30%" class="labelType">
<select name="cluster" onChange=getTable(this.value,tyear.value)>
<option value="00"> </option>
<option value="01">Nothern NCR</option>
<option value="02">Central NCR</option>
<option value="03">Sounthern NCR</option>
<option value="04">Nothern Luzon</option>
<option value="05">Central Luzon</option>
<option value="06">Sounthern Lozon</option>
<option value="07">Bicol Region</option>
<option value="08">Central Visayas</option>
<option value="09">Western Visayas</option>
<option value="10">Northern Mindanao</option>
<option value="11">Southern Mindanao</option>
<option value="12">Western Mindanao</option>
</select>
</td>
<td width="30%">&nbsp</td>
<td width="5%" class="labelType">
Year
</td>
<td width="30%" class="labelType">
<select name="tyear" onChange=getTable(cluster.value,this.value)>
<SCRIPT LANGUAGE="JavaScript">
var time = new Date();
var year = time.getYear();
if (year < 1900) year = year + 1900;
var date = year - 1;
var future = year + 2;
do {
document.write ("<OPTION value=\"" +date+"\">" +date+ "");
date++;
} while (date < future);
</script>
</select>
</td>
</tr>
</table>
</form>
</TD>
</TR>
<TR>
<TD valign="top">
<BR>
<jsp:getProperty name="targetSettingBean" property="targetTable" />
<BR>
<jsp:include page="footer.jsp" />
</TD>
</TR>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

khalidali63
05-09-2003, 07:44 AM
No, you can not pass variables between your jsp / javascript,
The only way to go from JavaSCript to jsp page will be using the HTTP Request,i.e submitting the form or calling a jsp page with values appended to the url.
The other way to get this done might be use of applet.

majorpain03
05-11-2003, 07:57 PM
thank you very much for that information... it really helps me... may be i'll use the first option, using the submit button... thank you very much. till next time...