0

I have an issue which I can't seem to fix.

I have a form and inside the form is a <textarea> which has text already populated. My problem is when I go to look at the form, the text displays outside of the textarea, not inside which is problematic!

I have the following:

HTML

<div class="passenger_Container">
    <div class="names">
        <strong>Joe Bloggs</strong>
    </div>

    <div class="package">
        <!-- passenger detail goes here. You will find the code in  includes/passenger_Detail.php -->
    </div>
</div> <!-- .passenger_Container -->

jQuery

j$('.names strong').click(function(e) {
        //find passenger ID - note input[name='customer_ID'] isn't shown in this example
        var customer_ID = j$(this).closest('.passenger_Container').find("input[name='customer_ID']").val();
        //Use jQuery to find placement of returned data
        var insert_Data = j$(this).closest('.passenger_Container').find('.package');


        j$.ajax({        
           type: "POST",
           url: "/include/passenger_Detail.php",
           data: { customer_ID_Data : customer_ID },
           success: function(data) {
                //console.log("Returned data: "+data);  
                //get returned data and add into appropriate place
                insert_Data.html(data);

                //re-initialise WYSIWYG editor. Notes is the ID to re-initialize 
                tinyMCE.execCommand('mceAddControl', true, 'notes');
           }
        }); 
    });

PHP - passenger_Detail.php

<?php
$customer_ID = $_REQUEST['customer_ID_Data'];
$query = mysqli_query($conn,"SELECT * FROM Customers WHERE customer_ID = ".$customer_ID." ORDER BY l_Name asc")
    or die("Error: ".mysqli_error($conn));
$row = mysqli_fetch_array($query);
$orderQuery = mysqli_query($conn,"SELECT * FROM Orders WHERE customer_ID=".$row['customer_ID']."")
    or die("Error: ".mysqli_error($conn));
$rowOrder = mysqli_fetch_array($orderQuery);
?>
<textarea type="text" name="notes" class="form-control notes" id="notes" />
<?php 
    echo $rowOrder['Notes']; 
?>
</textarea>

TL;DR - text echoed ($rowOrder['Notes'];) in PHP file displays outside of textarea, not inside.

I don't know what's causing this. Any help would be fantastic!

5
  • 1
    Stop looking at the PHP. Figure out what is wrong with the HTML you are generating (so look at the generated HTML by viewing the source (not inspecting the DOM!) in a browser). Use a validator. Then go back and stop the PHP from outputting whatever it is that is making it wrong. Commented Sep 17, 2014 at 8:32
  • 2
    Danger: You are vulnerable to SQL injection attacks that you need to defend yourself from. Commented Sep 17, 2014 at 8:33
  • 2
    Remove the / from id="notes" /> Commented Sep 17, 2014 at 8:33
  • @Quentin Thank you for pointing that out. That is on my "to do" list for sure :) Commented Sep 17, 2014 at 8:38
  • Thank you everyone else for the input.. Can't believe it was such a minuscule error. Commented Sep 17, 2014 at 8:38

1 Answer 1

4

Remove the trailing slash from the textarea opening tag:

Instead of:

<textarea type="text" name="notes" class="form-control notes" id="notes" />

it should be:

<textarea type="text" name="notes" class="form-control notes" id="notes">
Sign up to request clarification or add additional context in comments.

2 Comments

You beauty. Can't believe it was such a small error. After looking at the same page for more than 3 hours, it really gets to you! Thanks mate, greatly appreciated
Not worth an answer. Already answered in comments and now cannot be deleted by Akira.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.