We help IT Professionals succeed at work.

How to split a form vertically?

kishfy
kishfy asked
on
1,432 Views
Last Modified: 2008-12-31
How do I make it so a half of a form appears on the left side of the page and half on the right side of the page?
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
erikTsomikSystem Architect, CF programmer

Commented:

<form>
 
form fields
 
 
form fields
 
</form>
erikTsomikSystem Architect, CF programmer

Commented:
use float for each div either right or left

Author

Commented:
I made it using a "build your own" style form website and can't seem to make it work. Here is the code.
<table width="45%" style="border: 0px solid #000000; margin: 0; padding: 0; background-color: #FFFFFF;"><tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Name:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[1]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr><td colspan="2"><font color="#000000" size="2" face="Arial"><b> E-mail Address:<font color="#FF0000"> *</font> </b></font></td></tr><tr><td colspan="2"><input name="email" type="text" id="email" size="20" maxlength="100" /></td></tr><tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Address:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[2]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>City:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[3]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>State/Country:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[4]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>ZIP/Postal Code:</b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[5]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Contact Person:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[6]" type="text" value="" size="20" maxlength="30" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Contact Email:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[7]" type="text" value="" size="20" maxlength="40" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Phone:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[8]" type="text" value="" size="20" maxlength="40" /></font></td></tr>
 
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>What is your companys main business?</b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[9]" type="text" value="" size="20" maxlength="75" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>What other training do you represent?</b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input name="q[10]" type="text" value="" size="20" maxlength="75" /></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>How do you sell your training/services?<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input type="radio" name="q[11]" value="Retail/Store Location" />Retail/Store Location<br /><input type="radio" name="q[11]" value="Consultant Sales" />Consultant Sales<br /><input type="radio" name="q[11]" value="Internet" />Internet<br /><input type="radio" name="q[11]" value="Dont Leave Blank" />Dont Leave Blank</font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Number of sales people:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input type="radio" name="q[12]" value="0-25" />0-25<br /><input type="radio" name="q[12]" value="26-50" />26-50<br /><input type="radio" name="q[12]" value="51-75" />51-75<br /><input type="radio" name="q[12]" value="75+" />75+</font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><b>Total number of employees:<font color="#FF0000"> *</font></b></font></td></tr>
<tr bgcolor=""><td colspan="2"><font color="#000000" size="2" face="Arial"><input type="radio" name="q[13]" value="0-25" />0-25<br /><input type="radio" name="q[13]" value="26-50" />26-50<br /><input type="radio" name="q[13]" value="51-75" />51-75<br /><input type="radio" name="q[13]" value="75+" />75+</font></td></tr>
<tr><td colspan="2"><hr size="1" /></td></tr>
<tr><td colspan="2"><input name="submit" type="submit" value="Submit" /> </td></tr>
<tr><td><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>*</b></font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Required</font></td><td align="right"></td></tr>
</table></td></tr></table></div></form>
<!-- End myContactForm.com Form HTML -->

Open in new window

Author

Commented:
when i do the "float:left" and "float:right", the right div appears on the right side of the page, but only at the bottom of the left form.
Here's one way you can do it.  There's really no need to use messy table code:

<!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=utf-8" />
<title>Comment Box Example</title>
<style type="text/css">
/* Optional container div to control width of form */
#form_container {
	width:800px;
	margin:auto;
	}
.required {
	span-weight:bold;
	color:#ff0000;
}
label {
	font-weight:bold;
}
</style>
</head>
<body>
<div id="form_container">
  <div style="width:50%; float:left;">
    <h2>Contact Information</h2>
    <p><label>Name:<span class="required"> *</span></label><br />
      <input name="q[1]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>E-mail Address:<span class="required"> *</span></label> <br />
      <input name="email" type="text" id="email" size="20" maxlength="100" />
    </p>
    <p> <label>Address:<span class="required"> *</span></label><br />
      <input name="q[2]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>City:<span class="required"> *</span></label><br />
      <input name="q[3]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>State/Country:<span class="required"> *</span></label><br />
      <input name="q[4]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>ZIP/Postal Code:</label><br />
      <input name="q[5]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>Contact Person:<span class="required"> *</span></label><br />
      <input name="q[6]" type="text" value="" size="20" maxlength="30" />
    </p>
    <p> <label>Contact Email:<span class="required"> *</span></label><br />
      <input name="q[7]" type="text" value="" size="20" maxlength="40" />
    </p>
    <p> <label>Phone:<span class="required"> *</span></label><br />
      <input name="q[8]" type="text" value="" size="20" maxlength="40" />
    </p>
  </div>
  <div style="width:50%; float:left;">
    <h2>Company Details</h2>
    <p> <label>What is your companys main business?</label></span>
      <input name="q[9]" type="text" value="" size="20" maxlength="75" />
    </p>
    <p> <label>What other training do you represent?</label></span>
      <input name="q[10]" type="text" value="" size="20" maxlength="75" />
    </p>
    <p> <label>How do you sell your training/services?<span class="required"> *</span></label><br />
      <input type="radio" name="q[11]" value="Retail/Store Location" />
      Retail/Store Location<br />
      <input type="radio" name="q[11]" value="Consultant Sales" />
      Consultant Sales<br />
      <input type="radio" name="q[11]" value="Internet" />
      Internet<br />
      <input type="radio" name="q[11]" value="Dont Leave Blank" />
      Dont Leave Blank</p>
    <p> <label>Number of sales people:<span class="required"> *</span></label><br />
      <input type="radio" name="q[12]" value="0-25" />
      0-25<br />
      <input type="radio" name="q[12]" value="26-50" />
      26-50<br />
      <input type="radio" name="q[12]" value="51-75" />
      51-75<br />
      <input type="radio" name="q[12]" value="75+" />
      75+</p>
    <p> <label>Total number of employees:<span class="required"> *</span></label><br />
      <input type="radio" name="q[13]" value="0-25" />
      0-25<br />
      <input type="radio" name="q[13]" value="26-50" />
      26-50<br />
      <input type="radio" name="q[13]" value="51-75" />
      51-75<br />
      <input type="radio" name="q[13]" value="75+" />
      75+</p>
  </div>
  <div style="clear:both; text-align:center;">
    <hr size="1" />
    <p>
      <input name="submit" type="submit" value="Submit" />
      <span class="required">*</span>Required</p>
  </div>
  </form>
</div>
<!-- End myContactForm.com Form HTML -->
</body>
</html>

Open in new window

Author

Commented:
Thank you, this worked, but I changed the form width to 600px, and now the text boxes for "Company Information" appear next to the question instead of underneath.

Also, how do I get the "submit" button to submit to an email address?

Author

Commented:
I changed the font-size so now the text boxes appear underneath. How do I make the font-size for the radio buttons smaller?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Did this work for you then?

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.