By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,545 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,545 IT Pros & Developers. It's quick & easy.

Dynamically passing params to javascript function...

P: 10
Hi ,

the below statement is in a java program,in that xmlforDisplay is the java variable whose value i have to pass to the javascript function as follows, with the below code,I am getting the syntax error.Please help me...

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='javascript:eventHandlerFunction(document. formlob.lobselection.value,\''"+xmlforDisplay+"'\',null)'></td></tr></table><br><br>");
Jul 26 '07 #1
Share this Question
Share on Google+
11 Replies

epots9
Expert 100+
P: 1,351
Hi ,

the below statement is in a java program,in that xmlforDisplay is the java variable whose value i have to pass to the javascript function as follows, with the below code,I am getting the syntax error.Please help me...

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='javascript:eventHandlerFunction(document. formlob.lobselection.value,\''"+xmlforDisplay+"'\',null)'></td></tr></table><br><br>");
try this:
Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='javascript:eventHandlerFunction(document.formlob.lobselection.value,\'"+xmlforDisplay+"\',null)'></td></tr></table><br><br>");
i removed 2 single quotes around the xmlforDisplay...test that out.

good luck
Jul 26 '07 #2

P: 10
try this:
Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='javascript:eventHandlerFunction(document.formlob.lobselection.value,\'"+xmlforDisplay+"\',null)'></td></tr></table><br><br>");
i removed 2 single quotes around the xmlforDisplay...test that out.

good luck
Thanks for your reply.

Still I am getting the Syntax Error..:(
Jul 26 '07 #3

epots9
Expert 100+
P: 1,351
oh silly me...i forgot to remove the word javascript
Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick=eventHandlerFunction(document.  formlob.lobselection.value,\'"+xmlforDisplay+"\',null)'></td></tr></table><br><br>");
  2.  
it is not needed in the onlick event.

good luck
Jul 26 '07 #4

P: 10
oh silly me...i forgot to remove the word javascript
Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick=eventHandlerFunction(document.  formlob.lobselection.value,\'"+xmlforDisplay+"\',null)'></td></tr></table><br><br>");
  2.  
it is not needed in the onlick event.

good luck
unterminated String constant error in javascript, I am getting...
Jul 26 '07 #5

epots9
Expert 100+
P: 1,351
today is not my day...too many typos :(

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='eventHandlerFunction(document.  formlob.lobselection.value,\'"+xmlforDisplay+"\',null);'></td></tr></table><br><br>");
  2.  
i hope thats the last of my typos.

good luck
Jul 26 '07 #6

P: 10
today is not my day...too many typos :(

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='eventHandlerFunction(document.  formlob.lobselection.value,\'"+xmlforDisplay+"\',null);'></td></tr></table><br><br>");
  2.  
i hope thats the last of my typos.

good luck
This time syntax error...
Im also trying lot of trial and errors...:(
Jul 26 '07 #7

epots9
Expert 100+
P: 1,351
what does your eventHandlerFunction look like?

the error might be in there.
Jul 26 '07 #8

P: 10
what does your eventHandlerFunction look like?

the error might be in there.
I don't think so, because,I tried removing the \'"+xmlforDisplay+"\' portion in the code and given static content, then it's working fine wiht out errors.So, the only problem with this one is just appending accoring to javascript.

See the below one which I used in one of my javascript methods
The below one is fine. But I want the similarity in java method.There I am gettting the syntax error, with lot's of trials..:(

Expand|Select|Wrap|Line Numbers
  1. formedTd +='<tr><td align="center" width="30">'+label+'</td><td width="400"><a  href="#"  onclick="javascript:eventHandlerFunction(document.formlob.lobselection.value,null,\''+text+'\')">'+text+'</a></td>';            
  2.      formedTd +='<td width="15" align="center"><input type="radio" name="guid" value='+text+'></td></tr>';
Jul 27 '07 #9

gits
Expert Mod 5K+
P: 5,390
This time syntax error...
Im also trying lot of trial and errors...:(
hi ...

i'm not very familiar with java but the string must escape double-quotes when you start the onclick-handling with single-quotes ... otherwise the next single-quote would end the js-function and you will get an js-error

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='eventHandlerFunction(document.formlob.lobselection.value,\""
  2. + xmlforDisplay
  3. + "\",null);'></td></tr></table><br><br>");
kind regards
Jul 27 '07 #10

P: 10
hi ...

i'm not very familiar with java but the string must escape double-quotes when you start the onclick-handling with single-quotes ... otherwise the next single-quote would end the js-function and you will get an js-error

Expand|Select|Wrap|Line Numbers
  1. out.println("<input type='button' value='Transform' onclick='eventHandlerFunction(document.formlob.lobselection.value,\""
  2. + xmlforDisplay
  3. + "\",null);'></td></tr></table><br><br>");
kind regards
yeah, you are correct, this is working now.I'm Thankful to you again...:)
Jul 27 '07 #11

gits
Expert Mod 5K+
P: 5,390
hi ...

glad you got it working now ;) ... post again at TSDN when you have more questions ;) ...

and a MOD-notice:

please use the code tags when posting code ... it makes it easier to read the code and to find such little errors ;)

kind regards
Jul 27 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.