I have a drop-down list with 3 values, based on these values, different textareas are shows. I'm getting an error when trying to parse the values. Unable to set property 'value' of undefined or null reference. on inputList.value= '';
This worked in earlier version but not 8.0.08. Here is the relevant JS:
//Begin function cleanArray
function cleanArray(originalArray){
var newArray = new Array();
for(var i = 0; i < originalArray.length; i++){
if(originalArray[i] != ""){
newArray.push(originalArray[i]);
}
}
return newArray;
}
//End function cleanArray
//Begin function parseList
function parseList(textArea){
var textAreaControl = document.getElementById(textArea);
var itemArray = textAreaControl.value.split("\n");
var whichInput = "";
switch(textArea){
case "top_assoc_area":
whichInput = "top_assoc_list";
break;
case "client_group_area":
whichInput = "client_group_list";
break;
case "chain_area":
whichInput = "chain_list";
break;
case "mid_list_area":
whichInput = "mid_list";
break;
}
var finalArray = cleanArray(itemArray);
var inputList = document.getElementById(whichInput);
inputList.value = "";
for(var i = 0; i < finalArray.length; i++){
//if(i = 0){
// inputList.value = ' "' + finalArray[i] + '" ';
//}else{
// inputList.value = inputList.value + 'OR "' + finalArray[i] + '" ';
//}
if(inputList.value == ""){
inputList.value = "" + finalArray[i].trim() + "";
}else {
inputList.value = inputList.value + "," + finalArray[i].trim() + "";
}
}
}
//End function parseList
This message has been edited. Last edited by: <Kathryn Henning>,
WebFOCUS 8.0.08 Solaris HTML, PDF, XLS, CSV
September 15, 2015, 04:10 PM
Tamra
Hi Suzy,
When you say that your JavaScript worked in earlier versions can you please indicate which version.
Thank you for participating in the Focal Point Forum.
Kindest regards, Tamra Colangelo Focal Point Moderator Information Builders Inc.
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
September 16, 2015, 08:24 AM
eric.woerle
This looks more like a javascript issue instead of a webfocus issue. How are you passing text area into the gunction? Can you post that piece of code? Or the whole html? I would try putting an alert into the function to make sure you are getting a value passed for text area in the first place.
Eric Woerle 8.1.05M Gen 913- Reporting Server Unix 8.1.05 Client Unix Oracle 11.2.0.2
Susan, its because your switch(textArea), doesn't have a DEFAULT.. Something is being passed in, that doesn't follow your four CASEs.
Add an alert(textArea) right before the switch. See what is being passed.
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
September 18, 2015, 11:21 AM
Clayton Peacock
Hi Suzy,
In chrome press F12 to bring up developer tools, click on the console tab, refresh the procedure and hit the submit button in your procedure. Everything in the console.log(); will be output to the console tab so you can verify your code including parameters ans objects. You are able to add breakpoints in your script and then hover over the parameters to see what values they are.
All nice debugging techniques.
Hopefully below assists you.
-HTMLFORM BEGIN
<!DOCTYPE html>
<html lang="en">
<head>
<script>
//Begin function cleanArray
function cleanArray(originalArray){
var newArray = new Array();
for(var i = 0; i < originalArray.length; i++){
if(originalArray[i] != ""){
newArray.push(originalArray[i]);
}
}
return newArray;
}
//End function cleanArray
//Begin function parseList
function parseList(textArea){
-* var textAreaControl = document.getElementById(textArea);
-* var itemArray = textAreaControl.value.split("\n");
var textAreaText = document.getElementById(textArea).value;
console.log('Output for textAreaText: ' + textAreaText);
var itemArray = textAreaText.split("\n");
console.log('Output for itemArray: ' + itemArray);
var whichInput = "";
-* switch(textArea){
switch(textAreaText){
case "top_assoc_area":
whichInput = "top_assoc_list";
break;
case "client_group_area":
whichInput = "client_group_list";
break;
case "chain_area":
whichInput = "chain_list";
break;
case "mid_list_area":
whichInput = "mid_list";
break;
}
var finalArray = cleanArray(itemArray);
console.log('Output for finalArray: ' + finalArray);
}
//End function parseList
</script>
</head>
<body>
<textarea id="myTextArea">
1
2
3
4
</textarea>
<input type="button" onClick="parseList('myTextArea');" value="submit">
</body>
</html>
-HTMLFORM END
WF 8.1.05, MRE, BI Portal, App Studio, Apache Tomcat/8.0.21, MS Windows Server 2014 Express, MS Windows 10, Chrome