I have 2 boxes, ones for Name, second box is for Email.

They have images inbetween them on the code, so I can't see how to link them as 1 form..

Any ideas?

Dani AI

Generated

: the simplest intent behind the earlier replies from and is correct — the Name and Email controls must belong to the same form element to submit together. When layout (images, decorative markup, or a complex grid) makes wrapping everything inside one form impractical, HTML5 provides a neat alternative: form-associated controls via the form attribute. That keeps inputs visually separated by images while still tying them to one form.

Example using the HTML5 form attribute:

<form id="contactForm" action="/submit" method="post"></form>

<label for="name">Name</label>
<input id="name" name="name" type="text" form="contactForm">

<img src="spacer.jpg" alt="decorative">

<label for="email">Email</label>
<input id="email" name="email" type="email" form="contactForm">

Practical tips: always include label elements linked with for for accessibility, give each control a name for server-side processing, and use type="email" / required for basic client-side hints but still validate on the server. The form attribute is widely supported in modern browsers — check compatibility details on MDN — and for legacy support use a simple JavaScript fallback (copy values into hidden fields inside a real form before submit) or keep the controls nested in the form. Prefer CSS for layout instead of tables (as suggested by and ) unless the content is genuinely tabular.

MDN reference: input element — form attribute.

Recommended Answers

All 3 Replies

wrap it in form tags <form></form> cant be more specific without more information
post the code you are using, then its easy to point at 'there'

Form tags do the trick, here's an example

<form>
	<table>
		<tr>
			<td>Name</td>
			<td><input type="text" name="name"></td>
		</tr>
		<tr>
			<td colspan="2"><img width="200px" height="100px" src="images/myspacer.gif"/></td>
		</tr>
		<tr>
			<td>Email</td>
			<td><input type="text" name="email"></td>
		</tr>				
	</table>
</form>

Then just add an action to it

<form method="post" action="includes/process.php">

You can use table, for this

I have 2 boxes, ones for Name, second box is for Email.

They have images inbetween them on the code, so I can't see how to link them as 1 form..

Any ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.