0
for(int i = 0; i < ob.length; i++) {
  logger.logDebug(this.getClass(),"ob value check- "+ob[i].toString());
  String val=ob[i].toString();
  strXML1.append("<graph caption='City Wise Total Properties' xAxisName='City' yAxisName='Count' decimalPrecision='0' formatNumberScale='0'>")
         .append("<set name='")
         .append(ob[i].toString())
         .append("'  value='" + ob1[i].toString())
         .append( "'color='A186BE' link='javascript:drillDownReport1(2,"+val+")' />")
         .append("</graph>");
  } 

I am not getting the value of val using the following JavaScript function:

function drillDownReport1(reportnumber,val) {
    alert("val"+val);
}

Any help appreciated!

7
  • 1
    What are you getting in the alert? Commented Apr 2, 2013 at 11:14
  • please help for what? what you need to do and what is the question here? Commented Apr 2, 2013 at 11:17
  • You are asking or telling something? Completely unable to get you :( You can't just pick a portion of Code and put in a question like this. Indeed, you need to elaborate it a bit :) Commented Apr 2, 2013 at 11:20
  • @SubirKumarSao I am not getting any alert...It throws error value of val is undefined.......... Commented Apr 2, 2013 at 11:22
  • @ChamikaSandamal I need to get value of val in javascript function..But not able to get the value of val.Ob[i].tostring refers to cityname.... Commented Apr 2, 2013 at 11:25

3 Answers 3

2

It's because the javascript generated is, if val = "toto"

javascript:drillDownReport1(2,toto)' />")

and not

javascript:drillDownReport1(2,"toto")' />")

So you need to escape with quote your string. Like that:

.append( "'color='A186BE' link='javascript:drillDownReport1(2,\""+val+"')' />")
Sign up to request clarification or add additional context in comments.

1 Comment

I have used this already...By using above way I am not able to view the fusionchart graph to whom i want to pass above stringXMl
1

Use

var val=ob[i].toString();

instead of

String val=ob[i].toString();

?

Cause, you know, this is JavaScript.

1 Comment

This is JSP generating javascript.
0

Your problem is the way you are putting the value of val in your function

Since val is a string, you need to put that in quotes.

strXML1.append("<graph caption='City Wise Total Properties' xAxisName='City' yAxisName='Count' decimalPrecision='0' formatNumberScale='0'>")
        .append("<set name='")
        .append(ob[i].toString())
        .append("'  value='" + ob1[i].toString())
        .append( "'color='A186BE' link='javascript:drillDownReport1(2,\""+val+"\")' />")
        .append("</graph>");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.