3

I have a form that I'm using within Twitter Bootstrap 3. The form posts data to a mysql database and the placeholder values are echoed from the database. I have used a <textarea> input in the 'bio' field but for some reason the placeholder text behaves differently here. I can't drop a cursor and edit a particular word like I can with the other fields. Why is this?

<div class="form-group">
    <form class="" action="" id="edit_profile" method="post">
        <label>
                Name
              </label>
        <input id="user_name" name="user_name" type="text" placeholder="<?php echo $user_name ; ?>" value="<?php echo $user_name ; ?>" class="form-control input-md" required="">
</div>
Email
</label>
<input id="user_email" name="user_email" type="text" placeholder="<?php echo $user_email; ?>" value="<?php echo $user_email; ?>" class="form-control input-md" required="">
</div>

Bio
</label>

<textarea style="width:100%" value="<?php echo $bio; ?>" placeholder="<?php echo $bio; ?>" name="bio"></textarea>
</div>
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_session'] ?>">

<button type="submit" class="btn btn-small btn-green pull-right" id="submit">

              Save
            </button>
</form>

1 Answer 1

6

Textarea-text does not go in the value= it goes between the <textarea><?php echo $bio; ?></textarea> tags.

<textarea placeholder="This is a placeholder">This is the actual text</textarea>

You cannot have a value= on a <textarea> since it will stay the same regardless of what you put inside the <textarea> and therefore won't change anything regardless of what you type. (Try removing the "This is the actual text" in the example)

1
  • Thanks for the answer but I'm still unclear exactly what you mean. Like this? <input type="text" name="bio" value="<?php echo $bio; ?>" placeholder="<textarea><?php echo $bio;?></textarea>">
    – JulianJ
    Commented Nov 2, 2016 at 10:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.