Dynamically passing params to javascript function...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • haijdp
    New Member
    • Jun 2007
    • 10

    Dynamically passing params to javascript function...

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

    [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='javasc ript:eventHandl erFunction(docu ment. formlob.lobsele ction.value,\'' "+xmlforDisplay +"'\',null)' ></td></tr></table><br><br>" );[/CODE]
    Last edited by gits; Jul 26 '07, 01:05 PM. Reason: added CODE tags
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    Originally posted by haijdp
    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...

    [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='javasc ript:eventHandl erFunction(docu ment. formlob.lobsele ction.value,\'' "+xmlforDisplay +"'\',null)' ></td></tr></table><br><br>" );[/CODE]
    try this:
    [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='javasc ript:eventHandl erFunction(docu ment.formlob.lo bselection.valu e,\'"+xmlforDis play+"\',null)' ></td></tr></table><br><br>" );[/CODE]

    i removed 2 single quotes around the xmlforDisplay.. .test that out.

    good luck

    Comment

    • haijdp
      New Member
      • Jun 2007
      • 10

      #3
      Originally posted by epots9
      try this:
      [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='javasc ript:eventHandl erFunction(docu ment.formlob.lo bselection.valu e,\'"+xmlforDis play+"\',null)' ></td></tr></table><br><br>" );[/CODE]

      i removed 2 single quotes around the xmlforDisplay.. .test that out.

      good luck
      Thanks for your reply.

      Still I am getting the Syntax Error..:(

      Comment

      • epots9
        Recognized Expert Top Contributor
        • May 2007
        • 1352

        #4
        oh silly me...i forgot to remove the word javascript
        [code=java]
        out.println("<i nput type='button' value='Transfor m' onclick=eventHa ndlerFunction(d ocument. formlob.lobsele ction.value,\'" +xmlforDisplay+ "\',null)'> </td></tr></table><br><br>" );
        [/code]

        it is not needed in the onlick event.

        good luck

        Comment

        • haijdp
          New Member
          • Jun 2007
          • 10

          #5
          Originally posted by epots9
          oh silly me...i forgot to remove the word javascript
          [code=java]
          out.println("<i nput type='button' value='Transfor m' onclick=eventHa ndlerFunction(d ocument. formlob.lobsele ction.value,\'" +xmlforDisplay+ "\',null)'> </td></tr></table><br><br>" );
          [/code]

          it is not needed in the onlick event.

          good luck
          unterminated String constant error in javascript, I am getting...

          Comment

          • epots9
            Recognized Expert Top Contributor
            • May 2007
            • 1352

            #6
            today is not my day...too many typos :(

            [code=java]
            out.println("<i nput type='button' value='Transfor m' onclick='eventH andlerFunction( document. formlob.lobsele ction.value,\'" +xmlforDisplay+ "\',null);' ></td></tr></table><br><br>" );
            [/code]

            i hope thats the last of my typos.

            good luck

            Comment

            • haijdp
              New Member
              • Jun 2007
              • 10

              #7
              Originally posted by epots9
              today is not my day...too many typos :(

              [code=java]
              out.println("<i nput type='button' value='Transfor m' onclick='eventH andlerFunction( document. formlob.lobsele ction.value,\'" +xmlforDisplay+ "\',null);' ></td></tr></table><br><br>" );
              [/code]

              i hope thats the last of my typos.

              good luck
              This time syntax error...
              Im also trying lot of trial and errors...:(

              Comment

              • epots9
                Recognized Expert Top Contributor
                • May 2007
                • 1352

                #8
                what does your eventHandlerFun ction look like?

                the error might be in there.

                Comment

                • haijdp
                  New Member
                  • Jun 2007
                  • 10

                  #9
                  Originally posted by epots9
                  what does your eventHandlerFun ction look like?

                  the error might be in there.
                  I don't think so, because,I tried removing the \'"+xmlforDispl ay+"\' 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..:(

                  [CODE=javascript]formedTd +='<tr><td align="center" width="30">'+la bel+'</td><td width="400"><a href="#" onclick="javasc ript:eventHandl erFunction(docu ment.formlob.lo bselection.valu e,null,\''+text +'\')">'+text+' </a></td>';
                  formedTd +='<td width="15" align="center"> <input type="radio" name="guid" value='+text+'> </td></tr>';[/CODE]
                  Last edited by gits; Jul 27 '07, 07:51 AM. Reason: added CODE tags

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5390

                    #10
                    Originally posted by haijdp
                    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

                    [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='eventH andlerFunction( document.formlo b.lobselection. value,\""
                    + xmlforDisplay
                    + "\",null);' ></td></tr></table><br><br>" );[/CODE]

                    kind regards

                    Comment

                    • haijdp
                      New Member
                      • Jun 2007
                      • 10

                      #11
                      Originally posted by gits
                      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

                      [CODE=java]out.println("<i nput type='button' value='Transfor m' onclick='eventH andlerFunction( document.formlo b.lobselection. value,\""
                      + xmlforDisplay
                      + "\",null);' ></td></tr></table><br><br>" );[/CODE]

                      kind regards
                      yeah, you are correct, this is working now.I'm Thankful to you again...:)

                      Comment

                      • gits
                        Recognized Expert Moderator Expert
                        • May 2007
                        • 5390

                        #12
                        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

                        Comment

                        Working...