PDA

View Full Version : updateing text field with a value that has returns


Steven_Smith
10-23-2002, 04:27 AM
Hi :D

I have this script

<script>
opener.document.form1.email.value="<? echo $foo ?>"
</script>

That updates a text form field on another page.

My problem is that the $foo data has return in it

ie.
$foo="steve,steve@bakeacake.com\rjane,jane@bakeacake.com"

(I am making an addressbook)
My problem is that when $foo has \r in it it wont update, but without the \r it will update...

So my question is. HOw can I get around this problem...

Thanks
Steve

chrismiceli
10-23-2002, 04:35 AM
you could try making /r a variable and doing like this (i don't know php or whatever server side language that is)


hello = "/r"
$foo="steve,steve@bakeacake.com" + hello + " jane,jane@bakeacake.com"

glenngv
10-23-2002, 04:36 AM
is the email field a textarea or textbox?
if it's a textarea, it should obviously work since it is a multi-line field unlike the textbox

Steven_Smith
10-23-2002, 04:38 AM
Ahh, that gives me an idea. Thanks.

I'll let you know.

(I am using PHP with javascript)

Sometimes you just need to get a problem out for people to see so that someone can give some fresh eyes to it..

Thanks

Steven_Smith
10-23-2002, 05:22 AM
It was a text area.

You would think it would work. But it didn't. I make the $foo in PHP from an array. So I loop through the array then build the $foo array, which has "\r" in the array. But when the JAVASCRIPT runs with the "\r"'s involved it wouldn't submit.

So, as I am lopping the array, I update the other page, using


hello = "/r"

opener.document.form1.email.value=opener.document.form1.email.value+"<? echo $foo ?>" +hello

and that does the trick..

Thanks for your help people.