Field input type="text" does not fill in data with more than one word

2

When loading a data into an input, only the first word is loaded. Example:

'</form> <input type="text" value='.$result->name.' >';

$result->name contains the value "Hello World". Since the input only shows "Hello".

Can anyone help with this?

    
asked by anonymous 31.08.2015 / 19:28

3 answers

3

I believe the problem is the lack of quotes in value="" , it is treating the word "World" as if it were an attribute of the text field, ie its output should be: <input type="text" value=Ola Mundo> , to solve this, you need to put the quotation marks:

'</form>'."<input type=\"text\" value=\"{$result->name}\">";

You can also do this:

'</form><input type="text" value="'.$result->name.'">';
    
31.08.2015 / 19:37
2
<input type="text" value="'.$result->name.'">

add (")

or

document.getElementById('inputText').value = <?php $result->name ?>
    
31.08.2015 / 19:35
0

Try to use the maxlength attribute and put quotation marks around the value:

'</form> <input type="text" maxlength="100" value="'.$result->name.' ">';
    
31.08.2015 / 19:41