Jump to content

[SOLVED] Passing text back into a text box


johng

Recommended Posts

So I am having a problem passing text with spaces back into a text box. 

 

I am able to take it from the text box and put it into the database, and even to take it from the database and put it into a text field on a webpage.  But when I try to pass it back into a text box it only passes the first word.  The reason I am wanting to pass it back into a text box, in addition to other fields, is to edit it and put it back into the database.

 

To figure out where it is not working, I had it echo out right before the text box, and it prints as the full text, so the problem is somehow in the actual moving it into the text box. 

 

I have tried using text and varchar variables, and neither has worked so far.

 

Thanks in advance.

 

-John

Link to comment
Share on other sites

This is in a table, and in that table there are text boxes and text fields. The text I am trying to pass back is in a text box, code below.

 

 

There is a lot of code, because there are quite a few fields that I have text or numbers going into, but this is the function line:

 

function display_enter_eserveStaff($eserve_date, $eserve_time=null, $contact_id=null, $oh_cca=null, $oh_cc2=null, $oh_sca=null, $oh_keyers_act=null, $ia_cca=null, $ia_cc2=null, $ia_sca=null, $ia_keyers_act=null, $nv_cca=null, $nv_cc2=null, $nv_sca=null, $nv_keyers_act=null, $eserve_keyers=null, $eserve_notes=null, $row_id=null){

 

The variable I am trying to pass is $eserve_notes

And this is the line of code that creates the text box I am trying to get text back into:

 

echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\"  value=$eserve_notes></td>\r";

 

I echo-ed the variable out right before the text box, and it printed the entire thing, but when it goes into the text box, it only puts one word.  I have tried it with text, longtext, and varchar(100). 

Link to comment
Share on other sites

Let me explain what's happening.

 

<?php
//Let's say $eserve_notes = "One Two"

echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\"  value=$eserve_notes></td>";
?>

//Output:
<td colspan = 2><input name="eserve_notes" type="longtext"  value=One Two></td>

 

As you can see, the "Two" isn't connected to the value, so the browser that receives the html doesn't know what to do with it. So it takes only the "One" and ignores the rest.

 

Solution- add quotes around the value:

echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\"  value=\"$eserve_notes\"></td>";

Notice the double-quotes around $eserve_notes. Now the browser will know to what "Two" is connected :)

 

 

Orio.

Link to comment
Share on other sites

Thank you Orio, you are a genius.  I had tried to put quotes around it before, but didn't know you had to put the slash before them. 

 

Also, how do you get the forum to display as code like you have?

 

EDIT:  Also, do you know how to make the text box bigger?

 

Thanks in advance!

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.