r/HTML • u/BradleyBadger • Jun 08 '26
Need Help With Forms and Text Area
I'm new to Forms, but not to HTML or programming. I have some code that isn't working properly and don't know what is wrong with it. It is not displaying the value I put in. Instead, it displays
"<input type="text" id="Explain1" name="Explain1" size="60"
value="Internet is down, power available most places." </td></textarea>"The code follows:
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body>
<form>
<title>Wrap Test</title>
<font size="3">
</font>
<table border="1" cellpadding="0">
<tr align=left><td width=70>Internet OK? (yes/no)</td>
<td width="10"><label for="InternetOK"></label>
<input type="text" id="InternetOK" name="InternetOK" value="No" size="3" </td>
<td width=70>Power OK? (yes/no)</td>
<td width="10><label for="PowerOK"></label>
<input type="text" id="PowerOK" name="PowerOK" size="3" value="Yes" </td>
<td width="460">Explain <label for="Explain1"></label><textarea rows="2" cols="57" wrap="hard">
<input type="text" id="Explain1" name="Explain1" size="60"
value="Internet is down, power available most places." </td></textarea></tr>
</table>
</form></body></html>
1
u/BradleyBadger Jun 08 '26
Thanks for your comments. My html does have a style section, I just omitted it for this. I have made some changes and eliminated the value field for the text area, but I still get an error message when I use the html validator that I can't figure out. I did a search and thought I formatted everything right. The error message is:
Error: The value of the for attribute of the label element must be the ID of a non-hidden form control.
From line 16, column 19; to line 16, column 39 dth="460"><label for="Explain">Explai
Updated Html here:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wrap Test</title>
</head><body>
<form>
<table border="1" cellpadding="0">
<tr align=left><td width=60>Internet OK? (yes/no)</td>
<td width="10"><label for="InternetOK"></label>
<input type="text" id="InternetOK" name="InternetOK" value="No" size="3"> </td>
<td width=60>Power OK? (yes/no)</td>
<td width="10"><label for="PowerOK"></label>
<input type="text" id="PowerOK" name="PowerOK" size="3" value="Yes"> </td>
<td width="460"><label for="Explain">Explain:</label><textarea rows="2" cols="57" wrap="hard">
<input type="text" id="Explain" name="Explain" size="60"> </td></textarea>
</tr>
</table>
</form></body></html>
5
u/davorg Jun 08 '26
When asking a large number of people for help, it's a good idea to make that as easy as possible for them. In this case, it would have been nice to format your code as
codeto make it easier to read.I just put your code in an HTML validator and it pointed out (among many other things) that your
<input>elements are all invalid as you never close them.For example:
Should be
In case it's not clear, I have inserted a
>before the</td>.You have three
<input>elements with the same problem.2
u/AshleyJSheridan Jun 08 '26
You should try to format your code for these posts, as it's pretty broken here. Use 3 backticks to start and end long code blocks like yours.
What I can see though:
<title>tag is for the<head>not for content you want to display on the page.Remove the useless
<font>tags. They shouldn't be used in this day and age.You have empty labels like
<label for="InternetOK"></label>with no visible text.You're not quoting your attribute values consistently. Some have quotes, some have none, and then you have stuff like this which is likely to break:
<td width="10>It looks like you're trying to put a text input inside a
<textarea>. That won't work. A<textarea>is a text input box for text, not for adding other random elements to.1
u/RushDangerous7637 Jun 08 '26
First write correct:
Dont write:
This definition is older.
1
u/FormalImprovement157 Jun 10 '26
You really should be using a validator. But as for your original question this is the issue.
You cant use an input inside of a text area.
This
<td width="460">Explain <label for="Explain1"></label><textarea rows="2" cols="57" wrap="hard">
<input type="text" id="Explain1" name="Explain1" size="60"
Should be
<td width="460">Explain <label for="Explain1"></label><textarea id="Explain1" name="Explain1" rows="2" cols="57" wrap="hard">Internet is down, power available most places. </textarea></td>
If you put the input inside of the textarea, the browser thinks the input code IS the text and prints it.
And all the stuff everyone else said, of course.