Problem while Passing xml value into function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pingalkar
    New Member
    • Feb 2007
    • 6

    Problem while Passing xml value into function

    Hi,
    JavaScript [CODE=javascript]..
    var i=0;
    basechem="<UL>" ;
    while (i >= 0) {
    basechem = xml.getElements ByTagName("base chemical")[i];

    basechem = basechem.firstC hild.data;
    basehtml += "<LI><a href=# onClick=passChe micalName("+ i +")>" + basechem + "</a></LI>";
    [/CODE]
    Here instead of "i", i want to pass "basechem" but it wont work. why this happens, it take numeric value but cant take xml data.
    when i got this xml value, then i want to pass this value into parent window (which is a child window of another window) text box.
    please help.
    Last edited by pbmods; Jul 21 '07, 03:59 AM. Reason: Changed CODE language. Thanks for using CODE tags!
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    [CODE=javascript]
    basehtml += "<LI><a href=# onClick=passChe micalName('"+ basechem +"')>" + basechem + "</a></LI>";
    [/CODE]

    Hey there sorry I didn't answer this sooner just now seen the post but thats how you would do it by adding ' before and after '


    (" + whatever + ") would look like this (whatever) which would assume numeric only.

    but ('" + whatever + "') would look like this ('whatever') which is a string because of ' the quotes ' So now it will pass the information you want.

    Comment

    • pingalkar
      New Member
      • Feb 2007
      • 6

      #3
      I had tried this by using ('"+whatever+"' )
      but IE giving me Unterminated string error.

      Originally posted by iam_clint
      [CODE=javascript]
      basehtml += "<LI><a href=# onClick=passChe micalName('"+ basechem +"')>" + basechem + "</a></LI>";
      [/CODE]

      Hey there sorry I didn't answer this sooner just now seen the post but thats how you would do it by adding ' before and after '


      (" + whatever + ") would look like this (whatever) which would assume numeric only.

      but ('" + whatever + "') would look like this ('whatever') which is a string because of ' the quotes ' So now it will pass the information you want.

      Comment

      • iam_clint
        Recognized Expert Top Contributor
        • Jul 2006
        • 1207

        #4
        well is there any " or ' in your string?

        Comment

        Working...