Closed Thread Icon

Topic awaiting preservation: variables in URL from form (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8615" title="Pages that link to Topic awaiting preservation: variables in URL from form (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: variables in URL from form <span class="small">(Page 1 of 1)</span>\

 
quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 04-23-2003 13:56

Say I have a form (which thinking about it, I do), which you fill in, then you click one button to email it to me (all already done through php) and another button to sign my guestbook. The way I've done the second is to open a new window with the URL of the guestbook CGI, with the values in the form appended to the URL via JavaScript (can't remember if this is POST or GET). Trouble is, one of the form elements is a multi-line textarea, and forced line breaks don't convert into the URL. Is there some special character I can use, and how do I replace the line breaks with it using JavaScript?


home

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-23-2003 16:58

Ok, this is more of a server side problem.

The data is passed through the URL is not done using Javascript, it's a HTML thing. You could fix your problem using Javascript but eh, trust me, that'd be a pain in the arse. Most text manipulation is best left to the server side.

The forced line breaks are there but you need to convert them to <br> tags if you want to see them in HTML output. After all, a forced line break (also know as a hard return or carriage return) in a HTML page does nothing at all.

There's a string manip PHP function called nltobr() or somehting like that and it'll automagically convert any new-line characters (which actually look like "\n", just incase you were wondering) into <br /> tags. Or if you want to parse the text into individual well formed paragraphs then you'll need to regexp the chunks of text inbetween the "\n" characters and put <p> </p> at either end.

Anyways, it's a common problem and that's why there's a nltobr() function.

Just remember that data sent from a text input box is just that, text. If you want HTML you'll need to use PHP to manipulate that text into HTML.

[This message has been edited by Dracusis (edited 04-23-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 04-23-2003 17:15

quisja: I wouldn't pass the contents of a textarea via a URL (GET by the way ). There is a limit to the size of the URL and it just gets messy. I'd recommend you use POST instead.

___________________
Emps

FAQs: Emperor

quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 04-23-2003 19:07

Drac: I think you misunderstood slightly, I wasn't actually submiting a form, I just used Javascript to make a string (URL/?this=blah&that=blah) which I then opened in a new window. The page I am submitting to isn't something I can modify, so I don't want to mess about making a php script which it will all have to go through. I wasn't sure if this was a good way at the time. So is there a way for a form to have two submit buttons, which change it's action property depending on what you want it to submit to?


home

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-23-2003 19:13

sure. you could do something like this
<script>
function actionswitch(form) {
form.action = (form.elements['submit'].value == "email") ? "email.php":"guestbook.php";
return true.

}
</script>

<form name="something" onSubmit="return actionswitch(this)">

That would flip the action based on the submit button (if it's named submit).




.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu