Jump to content

Inserting line breaks


scavanaugh

Recommended Posts

I'm trying to get a mailing address to appear in a stacked format in my form mail email return.

The address is selected by the user from a drop down list then the form is submitted. It runs through a PHP form handler and is output as an HTML email.

 

I understand that something like this would possibly work, though it appears that there are a few variations.

$address = str_replace(",", ",\n", $_POST["shippingaddress"]);

 

The thing I'm really not sure about is where in the PHP form handler to insert this line of code?

Here's a link to the code for the form handler.

http://scavanaugh.com/TESTfm.txt

 

Any help with this is much appreciated.

 

Link to comment
Share on other sites

You're outputting an html formatted email, so just use std. html to format your email. Use a <br> tag between the lines of the address - no?

I tried this and it didn't work

 </li><label for="shippingaddress">Shipping Address</label><li>
           <li><select id="shipaddress" name="shippingaddress" dir="ltr" lang="en">
             <option>80 Allstate Parkway,<br /> Markham ON,<br /> L3R 6H3</option>
             <option>30 High Meadow, Toronto ON, M6L 2Z5</option>
             <option>4000 Victoria Park Avenue, Toronto ON, M2H 3P4 </option>
            
             ...
</select></li>
Link to comment
Share on other sites

is there a way to replace the commas with line breaks?

 

Didn't he just say line breaks are not supported in SELECT lists? The existence or not of a comma has nothing to do with it. If you weren't including this content in an email, you could use JQuery to build a "custom" select list object to display it however you want. But, I am pretty certain you can't run JavaScript in an HTML email. If you absolutely need to display with line breaks, you would have to provide a link into the email to open the form in a web page.

Link to comment
Share on other sites

Have you ever seen a list box with line feeds in it? Can't be done!

 

And - just why are you using a dropdown in an email? Is this going to be some kind of input to another script?

All I'm looking for is the Mailing address to appear in the email to the recipient like this

123 Maple St.

Nowhere

USA

 

Right now it gets emailed like this:

123 Maple St, Nowhere, USA

 

 

?

Link to comment
Share on other sites

So, you don't want the address to be displayed in a select list - that is important information. Do you have code that creates the email or are you using some 3rd party script for the email?

 

You could start by using a separate value from the label for the options:

[coed]<li><select id="shipaddress" name="shippingaddress" dir="ltr" lang="en">

    <option value="80 Allstate Parkway<br />Markham ON<br />L3R 6H3">80 Allstate Parkway, Markham ON, L3R 6H3</option>
    <option value="30 High Meadow, Toronto ON<br />M6L 2Z5">30 High Meadow, Toronto ON, M6L 2Z5</option>

    <option value="4000 Victoria Park Avenue<br />Toronto ON<br />M2H 3P4">4000 Victoria Park Avenue, Toronto ON, M2H 3P4</option>[/code]

 

If you are using a 3rd party script to generate the emails, it will likely take more effort to find and modify the right code to work properly. But, if you wrote the code to generate the email, then show the lines that generate the content from the POSTed values.

Link to comment
Share on other sites

So, you don't want the address to be displayed in a select list - that is important information. Do you have code that creates the email or are you using some 3rd party script for the email?

 

You could start by using a separate value from the label for the options:

[coed]<li><select id="shipaddress" name="shippingaddress" dir="ltr" lang="en">

    <option value="80 Allstate Parkway<br />Markham ON<br />L3R 6H3">80 Allstate Parkway, Markham ON, L3R 6H3</option>
    <option value="30 High Meadow, Toronto ON<br />M6L 2Z5">30 High Meadow, Toronto ON, M6L 2Z5</option>

    <option value="4000 Victoria Park Avenue<br />Toronto ON<br />M2H 3P4">4000 Victoria Park Avenue, Toronto ON, M2H 3P4</option>[/code]

 

If you are using a 3rd party script to generate the emails, it will likely take more effort to find and modify the right code to work properly. But, if you wrote the code to generate the email, then show the lines that generate the content from the POSTed values.

Yeah I tried that already and it didn't change anything.

Link to comment
Share on other sites

So, you don't want the address to be displayed in a select list - that is important information. Do you have code that creates the email or are you using some 3rd party script for the email?

 

You could start by using a separate value from the label for the options:

[coed]<li><select id="shipaddress" name="shippingaddress" dir="ltr" lang="en">

    <option value="80 Allstate Parkway<br />Markham ON<br />L3R 6H3">80 Allstate Parkway, Markham ON, L3R 6H3</option>
    <option value="30 High Meadow, Toronto ON<br />M6L 2Z5">30 High Meadow, Toronto ON, M6L 2Z5</option>

    <option value="4000 Victoria Park Avenue<br />Toronto ON<br />M2H 3P4">4000 Victoria Park Avenue, Toronto ON, M2H 3P4</option>[/code]

 

If you are using a 3rd party script to generate the emails, it will likely take more effort to find and modify the right code to work properly. But, if you wrote the code to generate the email, then show the lines that generate the content from the POSTed values.

Hi I tried inserting <br /> as suggested but didn't work. I posted a link to the form handler code (3rd party code) in my first post, here it is again

 http://scavanaugh.com/TESTfm.txt

Take a look if you like and let me know what you think.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.