XHTML Clarification: forms[SOLVED]

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

XHTML Clarification: forms[SOLVED]

Post by raghavan20 »

I want a way to make forms xhtml compliant where tables are used.
I have a table and two fields have to be displayed.
each field is in a <td>. I dont know how to place the <form> tag to make it XHTML compliant.
any help appreciated.

The code below does not validate.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">
<table>
<tr>
<td>
<form action="">
	<input type="text" value="" />
</td>
<td>
	<input type="text" value="" />
</form>
</td>
</tr>
</table>
</body>
</html>
Last edited by raghavan20 on Tue Sep 13, 2005 5:29 pm, edited 1 time in total.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: XHTML Clarification: forms

Post by Roja »

raghavan20 wrote: each field is in a <td>. I dont know how to place the <form> tag to make it XHTML compliant.
any help appreciated.
The order you open tags matter - you cannot stagger tags.

You did: Form, open. Input, open, close. TD, close.

Wait.. Where is a td there? Its OUTSIDE the form. Needs to be inside.

Lets just put the form outside the whole table, and then you can get as crazy as you want with the table. :)

Code: Select all

<form action="">
<table>
<tr>
<td>
	<input type="text" value="" />
</td>
<td>
	<input type="text" value="" />
</td>
</tr>
</table>
</form>
</body>
</html>
[/quote]
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

i know that i am not closing <form> tags in my example.
but did not know that taking <form> tags out of <table> would be xhtml compliant.

actually i had a different large case which i managed to do it.
had something similar to this

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">

<table>
<tr>
	<td>
		<form name='frm1' action="">
			<input type="text" value="" />
	</td>
	<td>
			<input type="text" value="" />
		</form>
	</td>
</tr>
<tr>
	<td>
		<form name='frm2' action="">
			<input type="text" value="" />
	</td>
	<td>
			<input type="text" value="" />
		</form>
	</td>
</tr>
</table>
</body>
</html>

but now changed to

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">

<table>
<tr>
	<td>
		<form name='frm1' action="">
		<table>
			<tr><td>
			
				<input type="text" value="" />
			</td>
			<td>
					<input type="text" value="" />
			</td></tr>
		</table>
		</form>
	</td>
</tr>
<tr>
	<td>
		<form name='frm2' action="">
		<table>
			<tr><td>
			
				<input type="text" value="" />
			</td>
			<td>
					<input type="text" value="" />
			</td></tr>
		</table>
		</form>
	</td>
</tr>
</table>
</body>
</html>
Post Reply