473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2822
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

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

Similar topics

2
by: Tole | last post by:
hi all, i have some doubts in passing variables by references in php. i usually use class blah { function Params( &$params) { $this->params =& $params; } }
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
1
by: craigkenisston | last post by:
Hi, I'm trying to create a generic function to call stored procedures in a SQL Server database. I'm passing the params, values and the direction of the params in arrays. The function is...
4
by: Pritcham | last post by:
Hi all I've got a number of classes already developed (basic entity classes) like the following: Public Class Contact Private _firstname as String Private _age as Integer Public Property...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
6
by: haijdp | last post by:
Hi, I am using the following javascript method inside a js file. function createDivRow(label,text) { var formedTd = '<tr><td>' + label + '</td><td> <a href="#"...
1
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function ////////////////////////////////////////////////////////////////////////////////////...
3
by: q-rious | last post by:
Hello All, 1. I would like to pass some variables (x and y below) from Javascript to PHP, process them in PHP, and return some other variables (a abd b) back to Javascript. --(x,y)--...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.