transferring strings from php to javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Unregistered

    transferring strings from php to javascript


    Hi there,

    i got this javascript-function that changes the entries of a selectbo
    depending from the selection of another selectbox:

    function changeBezug(sel ectedEntry, '$exhibits', .....) {}

    the string '$exhibits' holds all the entries for the option Entry i
    the first selectbox;
    Unfortunately i get javascript error unterminated string literal an
    the error pointer points at the first apostroph:
    function changeBezug(sel ectedEntry, '

    I tried replacing all special chars in $exhibits, even putting th
    string directly into the function code with php and tried using quote
    instead..

    Now im out of ideas!
    Maybe im using the wrong replacement for the apostroph...
    i use ' is that wrong? i also tried ' to no good either..
    what's the right one?

    Could it be sth else?


    Thanks
    Christia

    Unregistered
    -----------------------------------------------------------------------
    Posted via http://www.forum4designers.co
    -----------------------------------------------------------------------
    View this thread: http://www.forum4designers.com/message37448.htm

  • kaeli

    #2
    Re: transferring strings from php to javascript

    In article <Guest.10ndgn@m ail.forum4desig ners.com>,
    Guest.10ndgn@ma il.forum4design ers.com enlightened us with...[color=blue]
    >
    > Hi there,
    >
    > i got this javascript-function that changes the entries of a selectbox
    > depending from the selection of another selectbox:
    >
    > function changeBezug(sel ectedEntry, '$exhibits', .....) {}
    >[/color]

    You don't put apostrophies in the function definition. They go in the
    call.

    function myFunction(var1 , var2)
    {
    var1.value=var2 ;
    }

    <script ...>
    ....
    myFunction(sele ctedEntry, 'string literal');
    ....
    </script>

    --
    --
    ~kaeli~
    Never mess up an apology with an excuse.



    Comment

    • Unregistered

      #3
      Re: transferring strings from php to javascript


      yeah, of course, i copied that copied that incorrectly from my script
      Its actually just as you wrote

      Unregistered
      -----------------------------------------------------------------------
      Posted via http://www.forum4designers.co
      -----------------------------------------------------------------------
      View this thread: http://www.forum4designers.com/message37448.htm

      Comment

      • kaeli

        #4
        Re: transferring strings from php to javascript

        In article <Guest.10p2ko@m ail.forum4desig ners.com>,
        Guest.10p2ko@ma il.forum4design ers.com enlightened us with...[color=blue]
        >
        > yeah, of course, i copied that copied that incorrectly from my script.
        > Its actually just as you wrote.
        >
        >[/color]

        Ah, then you must have another single quote in the string.
        You can't do that.

        I myself never found a good way around that and simply disallowed double
        quotes in the input and used double quotes for the attribute. Single
        quotes could then be used in the input with no problems.

        If that was not the problem, view the source of your document and post
        what the browser actually sees (no PHP code).

        --
        --
        ~kaeli~
        With her marriage, she got a new name and a dress.



        Comment

        Working...