Focal Point
Calling FOCUS/Javascript

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5001040002

December 06, 2006, 07:44 AM
gkata
Calling FOCUS/Javascript
I have a .NET/WebFOCUS reporting application. I have an up-front asp page. On the asp page a user can select from many drop-down boxes. However, some combinations of reports and drop-down boxes are not allowed. I need to incorporate some javascript in the asp page to check for these invalid combinations. I can't seem to get the javascript to work, even the simple alert will not display. Any ideas?

Here's the snipet of the html code from the asp page:



CVASalesReporting




<script language="javascript">

function valForm() {

//var selected_report = document.Form1.document.getElementsByName("ucWUC1:RPTSEL_LBOX");
//getElementsByTagName('ucWUC1:RPTSEL_LBOX');

//var selected_report = window.Form1.document.getElementsByName("ucWUC1:RPTSEL_LBOX");

window.alert ("This is a Javascript Alert")

//if (selected_report != "TERRSALES") {
//window.alert (selected_report)
//window.alert ("Invalid report combination.")
//return false;
//}
//else return true;
}

//alert(document.Form1.getElementsByTagName.toString("ucWUC1:RPTSEL_LBOX"));
//alert(pagesObj.options[pagesObj.selectedIndex].value);
//}


function submitForm()
{
var strAction = document.Form1.action;
var strViewState = document.Form1.__VIEWSTATE.value;
document.Form1.target="_new";
// document.Form1.action="http://citms042.arvinmeritor.com/ibi_apps/WFServlet"
document.Form1.__VIEWSTATE.value="";
// document.Form1.submit();

document.Form1.onclick="javascript:valForm()"
//document.Form1.submit(onClick="valForm()")

document.Form1.target="";
document.Form1.action=strAction;
document.Form1.__VIEWSTATE.value=strViewState;
}





 














December 06, 2006, 09:29 AM
Francis Mariani
This is a WebFOCUS forum. ASP is not something we do often. Have you tried an ASP forum? This site might help: http://aspjavascript.com/


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 06, 2006, 09:39 AM
TexasStingray
I am assuming that you have a link that call the submitForm java script function. In the submitForm function at the top add an alert to make sure it is being called.
function submitForm()
{
alert("Start submitForm...");
}


see if that works.
then if it does call valForm like so.

function submitForm()
{
alert("Start submitForm...");
valForm();
}


Hope this helps




Scott

‘form’ is a section of a document. It is like a tree. Starts from
navigator -> window -> document -> form and so on. We can not have document as pasrt of form itself. Here is what you have in you code.
 
var selected_report = document.Form1.document.getElementsByName("ucWUC1:RPTSEL_LBOX");
 

You can either use (because you are passing this form as value)
var selected_report = Form1.ucWUC1:RPTSEL_LBOX.value;
  


OR

I would try changing it to:
var selected_report = document.getElementsByName("ucWUC1:RPTSEL_LBOX");
  


Here is an example
 

<html>

<head>


<title>JavaScript Validation</title>

<script type="text/javascript">

function valForm() {

var selected_report = document.getElementsByName("ucWUC1:RPTSEL_LBOX");

window.alert ("This is a Javascript Alert")

// OR the following message

if (!(selected_report == "TERRSALES")) {//Provided ucWUC1:RPTSEL_LBOX is passing this value
window.alert (selected_report + "is an invalid report combination.")
return false;
}
return true;
}

//alert(document.Form1.getElementsByTagName.toString("ucWUC1:RPTSEL_LBOX"));
//alert(pagesObj.options[pagesObj.selectedIndex].value); 
//}


</script>

</head>

<body bgcolor="#ffffff">

<form name="Form1" action='/ibi_apps/WFServlet' method='post' onSubmit="return valForm[this);">

<h2 align="center">Please Enter Your Details Below</h2>



Report Name: <input type="text" name="ucWUC1:RPTSEL_LBOX"></p>



<input type="submit" name="send" value="Send Details"></p>

</form>

</body>

</html>
 

This message has been edited. Last edited by: ok_dhs,


Prod: WebFOCUS 7.1.3 on Linux Kernel-2.6.5 zSeries 64bit/Apache Tomcat/5.0.28 JAVA version 1.4.2_11 server
Here's the solution:
<%@ Register TagPrefix="uc1" TagName="CVAWebUserControl3" Src="usercontrols/CVAWebUserControl3.ascx" %>
<%@ Register TagPrefix="uc1" TagName="CVAWebUserControl1" Src="usercontrols/CVAWebUserControl1.ascx" %>
<%@ Register TagPrefix="uc1" TagName="CVAWebUserControl2" Src="usercontrols/CVAWebUserControl2.ascx" %>
<%@ Page language="c#" Codebehind="CVASalesReporting.aspx.cs" AutoEventWireup="false" Inherits="CVASalesReporting.web.CVASalesReporting" %>
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
	<title>CVASalesReporting</title>
	<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
	<meta content="C#" name="CODE_LANGUAGE">
	<meta content="java_script" name="vs_defaultClientScript">
	<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	<script language="javascript">
		
function valForm() {

var selected_report = document.getElementById("ucWUC1:RPTSEL_LBOX").value;

var selected_mkt_report = document.getElementById("ucWUC1:MKTP_LBOX").value;

if (selected_report == "TERRSALES" && selected_mkt_report != "All Marketing Programs")
{
window.alert ("Invalid report combination.")
return false
}
else if (selected_report == "STSALES" && selected_mkt_report != "All Marketing Programs") 
{
window.alert ("Invalid report combination.")
return false
}
else if (selected_report == "REBATE" && selected_mkt_report != "All Marketing Programs") 
{
window.alert ("Invalid report combination.")
return false
}
else if (selected_report == "CVAMIXVL" && selected_mkt_report != "All Marketing Programs") 
{
window.alert ("Invalid report combination.")
return false
}
else if (selected_report == "CVAMVYTD" && selected_mkt_report != "All Marketing Programs") 
{
window.alert ("Invalid report combination.")
return false
}
else return true;
}

	
function submitForm()
  {  
	var strAction = document.Form1.action;
	var strViewState = document.Form1.__VIEWSTATE.value;
         document.Form1.target="_new";
         document.Form1.action="http://citmsxxx.xxxxxxx.com/ibi_apps/WFServlet"
	document.Form1.__VIEWSTATE.value="";
	document.Form1.submit();

		document.Form1.target="";
		document.Form1.action=strAction;
		document.Form1.__VIEWSTATE.value=strViewState;
	  }
		</SCRIPT>
	</HEAD>
	<body bgColor="#cccccc" ms_positioning="GridLayout">
	<form id="Form1" method="post" onSubmit="return valForm[this)" runat="server">
	 
	<table cellSpacing="0" cellPadding="5" border="1">
	<tr>
	<td><uc1:cvawebusercontrol1 id="ucWUC1" runat="server" OnCommand="ucWUC1_Command"></uc1:cvawebusercontrol1></td>
	</tr>
	<tr>
	<td><uc1:cvawebusercontrol2 id="ucWUC2" runat="server" OnCommand="ucWUC2_Command"></uc1:cvawebusercontrol2></td>
	</tr>
	<tr>
	<td><uc1:cvawebusercontrol3 id="ucWUC3" runat="server" OnCommand="ucWUC3_Command"></uc1:cvawebusercontrol3></td>
	</tr>
	</table>
	<asp:literal id="ljava_script" Runat="server"></asp:literal></form>
	</body>
</HTML>

This message has been edited. Last edited by: Kerry,