Hello all:

I am trying to pass a multiple line variable to another page.

I am assigning the variable in javascript like so:

var description1=<? echo "\"" . "Order No: " . $quoteno . "\r\n" . "Desc: " . $bcfg . "\r\n" . "Insul: " . $instype1 . "\r\n" . "Doors Incld: " . $dooropt1 . "\r\n" . "Mfgr: " . $doorman1 . "\""; ?>;

I then propogate a form value with this variable using the following method in javascript.

document.PURCHASE.DESCRIPTION.value=description1a;

The form then passes the variable the convential way:

<FORM ACTION="agreement.php" METHOD="POST">

I am getting a "unterminated string constant" error because of
the carriage returns $ newlines I have in the string.

It functions fine without them....any ideas?

I will eventually be passing this variable to an online payment
processing form, which is beyond my control from there.

Thanks

    My only suggestion is to use another character as the newlines and expand them when you get the POST.

    eg
    var description1 = <? echo "\"" . "Order No: " . $quoteno . "|" . "Desc: " . $bcfg . "|" . "Insul: " . $instype1 . "|" . "Doors Incld: " . $dooropt1 . "|" . "Mfgr: " . $doorman1 . "\""; ?>;

    In agreement.php

    $desc = str_replace( '|' , "\r\n" , $_POST['description1'] );

    HalfaBee

      Thanks for your speedy reply:

      That will work great for pages I have control over, but I eventually will be passing this variable to a payment processing
      page written in cold fusion at VeriSign. This site is beyond my
      control

      I am having the same problem passing to their page.
      I have written VeriSign about this problem.....still waiting for
      an answer.

      Thanks a bunch........

        Let javascript add the newlines

        var desc = "value1"+"\r\n" .......

        HalfaBee

          Thanks again for your reply:

          If you will look back you see I am using javascript to create my
          variable.

          The problem is I'm passing this variable to a cold fusion web site.
          Once there I have no control. I need a way to pass carriage returns and newlines that cold fusion will recognize.

          Thanks.......

            You are creating the whole string in php.
            I was suggesting only create bits with php and let JS and the CRLF.

            var desc = "<? echo 'value1' ?>"+"\r\n" + "<? echo 'value2' ?> + "\r\n" .......

            HalfaBee

              Thanks HalfaBee

              I'll give it a try and let you know.

              Gary

                I'd like to add my 5 cents.

                Why don't you pass the variable in a hidden field:
                <input type="hidden" name="description" value="DESCRIPTION" value="the description goes here">

                But I'm not sure if it is allowed to have a line break in the value of a hidden field. And you should replace " inside the description using htmlspeccharacters function.

                  Write a Reply...