Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
To use javascript in custom parameter page.
Rahul Kushwaha
<p>Hi ,</p>
<p> </p>
<p>I am not able to use javascript in custom parameter page. as "birt:paramDef " has not any attribute related to event like onclick ,onchange etc.</p>
<p> </p>
<p>is any other way to sue script ?</p>
<p> </p>
<p>Please help !!</p>
Find more posts tagged with
Comments
kclark
<p>I'll have to dig up some old example I've got somewhere on my desktop, but if I remember right you should be able to assign an ID in the parameters then call it like you normally would in some JS</p>
<pre class="_prettyXprint">
<script>
var city = document.getElementById('CITY');
</script>
<birt:paramDefid="11"name="CITY" id="CITY"/></pre>
<p>I'll find the old example and edit this if needed.</p>
Rahul Kushwaha
<p>Hi ,</p>
<p> </p>
<p>Thanks <span style="font-size:14px;">Kristopher </span>, I need to use event like onclick ,onchange etc. on select element but "birt:paramDef " does not provide any way .</p>
<p> </p>
<p>so is any other way to proceed further?</p>
kclark
<p>Rahul, sorry for the late reply
<br>
<br>
Here's what I usually do, there's probablly a better way to handle this. I grab the values from my parameters after page load adding them into an array. Then I build a "custom, custom parameter" in HTML using JavaScript. Once I've done that I can use normal JavaScript functionality <br>
</p>
<pre class="_prettyXprint _lang-auto _linenums:0">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="/birt.tld" prefix="birt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script>
var customerNameValues = [];
// Get the values from the hidden parameter
function getValues() {
var customerName = document.getElementById('6');
for(var i=0; i<customerName.options.length; ++i) {
customerNameValues[i] = customerName.options[i].value;
}
buildParams();
}
// Build's the new parameter
function buildParams() {
var optionsHTML = document.getElementById('CustomerNameHTML');
for(var i=0; i<customerNameValues.length; i++) {
var newOption = document.createElement('option');
// Add the text from our array
newOption.text = customerNameValues[i];
// Add the new option to the list
optionsHTML.add(newOption);
}
}
// This is the function for our custom custom parameter
function doSomething() {
alert("Do something...");
}
// TODO: Add more events for the HTML parameters
// Get the parameters after page load
if (window.addEventListener) {
window.addEventListener("load", getValues, false);
}else if(window.attachEvent) {
window.attachEvent("onload", getValues);
}else{
window.onload = getValues;
}
</script>
</head>
<body>
<div id="hidden">
<birt:parameterPage id="report1" name="page1" reportDesign="customparameters.rptdesign" isCustom="true" pattern="frameset">
<birt:paramDef id="6" name="CustomerName"/>
</birt:parameterPage>
</div>
<div>
<select id='CustomerNameHTML' onClick="doSomething();"></select>
</div>
</body>
</html>
</pre><p>That's not a complete example but it'll run and show you how I approach this. You can either choose to change the actual parameters based on the user's choices and then click submit for them. But I like to reconstruct the URL passing the parameter values there and then forward them using window.location</p>