469,640 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,640 developers. It's quick & easy.

Dynamically passing params to javascript function...

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
11 2667
epots9
1,351 Expert 1GB
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
haijdp
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
1,351 Expert 1GB
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
haijdp
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
1,351 Expert 1GB
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
haijdp
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
1,351 Expert 1GB
what does your eventHandlerFunction look like?

the error might be in there.
Jul 26 '07 #8
haijdp
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
5,390 Expert Mod 4TB
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
haijdp
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
5,390 Expert Mod 4TB
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.

Similar topics

2 posts views Thread by Tole | last post: by
1 post views Thread by craigkenisston | last post: by
3 posts views Thread by q-rious | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.