473,399 Members | 3,656 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,399 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 2823
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.