This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Nov 13, 2013, 4:19 PM
3 Posts

Clientside JS

  • Category: Other
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: Clientside JS
  • Replies: 4

Hi all,

Help needed with the following problem.

please take a look at the next cliewntsided JS

for (i=2; i<=4; i++) {
elem1 = "#{id:a1_"+i+"1}"; 
elem2 = "#{id:a"+i+"_11}"; 
if (document.getElementById(elem1).value == 0) {document.getElementById(elem2).value = 1;} 
else {document.getElementById(elem2).value = 0;}; 
}

 

The getElementById method does not understand elem1 and elem2

What am i doing wrong?

 

Regards, Marcel

 

 

Nov 14, 2013, 9:50 AM
30 Posts
basics

Proper way to calculate your elem1 variable is:

 

elem1 = ' "#{id:a1_' + i + "1}"+'" ';

 

Pay attention to single quotation marks. They are necesary to get your double quotation marks into string.
Have a nice day

Nov 14, 2013, 7:49 PM
3 Posts
nope, still doesn's work

thanks Tomislav,

I tried te code using an alert and still having the same problem:

for (i=2; i<=10; i++) {
  elem1 = ' "#{id:a1_' + i + '1}' + '" ';
alert(elem1)
}

the alert results in  ' " " ' (two double_quotes)

 

Nov 15, 2013, 9:19 AM
30 Posts
full code

var elem1 is in string format. To execute your code written like that, you must use eval() function.

So your full code would be something like this:

 

elem1 = ' "#{id:a1_' + i + "1}"+'" ';

var fullStringToExecute = "document.getElementById(" + elem1 + ").value";

if (eval(fullStringToExecute) == 0) {.......

 

Try it and let me know how it goes!

Nov 15, 2013, 9:59 PM
3 Posts
sorry, still doesn't work

I did the next test, putting the code in a button and try to set the value for field a1_21 to 3

i = 2;
elem1 = ' "#{id:a1_' + i + '1}'+'" ';
var fullStringToExecute = "document.getElementById(" + elem1 + ").value";
eval(fullStringToExecute) = 3; 

When i send alert(fullStringToExecute) it shows the next string

document.getElementById("").value

It looks like xpages don't understand the special chars like #{:  in a string.

Is it possible that i should use escape chars for those special chars?

I will give it a try using escape chars .

thnx


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal