Solved

Help with formatting a web form (HTML)

Posted on 2007-11-14
5
199 Views
Last Modified: 2010-04-09
Hi

I need help formatting a form on a website (not done forms before).  I basically want the questions to appear on the left and the input boxes to appear on the right (in the same position down the page).  Some of the questions may be a few sentences long so the input box on the right would need to be in line with the top of the first line of the question.  I know this is easy but I'm not experienced in forms or formatting and I haven't got time to work it out as I'm meant to be working on the content!  Therefore 500 points.  Any extra coding to make the form look smarter such as a box etc would be appreciated.  Cheers.  

<!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>Untitled Document</title>
<style>

.labeltxt {margin-right:10px; width:190px; background-image:none}
.row {width:420px; margin-left:10px; background-image:none}
</style>
</head>
<body>

<form action="cover_calculator_process.do" method="post">
<h3>FORM</h3>
      
<div class="row">                         
<label for="val1">
<span class="labeltxt">Question 1: XXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX</span>
<input id="val1" name="val1" class="calc" type="text" value="" />
</label>
</div>
            
<div class="row">                         
<label for="val2">
<span class="labeltxt">Question2: XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX</span>
<input id="val2" name="val2" class="calc" type="text" value="" />
</label>
</div>
                  
<div class="row">                         
<label for="val3">
<span class="labeltxt">Question 3: XXXXXXXXXXXXXXXXXXXXXXXXXXXX</span>
<input id="val3" name="val3" class="calc" type="text" value="" />
                   
<div class="row">                         
<label for="val4">
<span class="labeltxt">Question 4: XXXXXXXXXXXXXXXXXXXXXXXXXXXX</span>
<input id="val4" name="val4" class="calc" type="text" value="" />        
</label>
</div>
                  
<div class="row">
<input class="button" type="submit" name="calculate" value="Calculate" />
</div>
</form>
                    
</body>
</html>
0
Comment
Question by:dvsuk
5 Comments
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20280015
You mean something like this:

<!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>Untitled Document</title>
<style type="text/css">
.row{width:600px; clear:both; border:1px dotted #f1f1f1; margin:4px 0; padding:4px;}
label{float:left; width:250px; }
.row {width:420px; margin-left:10px; background-image:none}
.calc{float:left; margin-top:6px;}
.button{float:right; margin-right:10px;}
</style>
</head>
<body>

<form action="cover_calculator_process.do" method="post">
<h3>FORM</h3>
     
<div class="row">                        
<label for="val1">
<span class="labeltxt">Question 1: How many questions can be asked in one form for example?</span>
</label>
<input id="val1" name="val1" class="calc" type="text" value="" />
</div>
           
<div class="row">                        
<label for="val2">
<span class="labeltxt">Question2: Less text?</span>
</label>
<input id="val2" name="val2" class="calc" type="text" value="" />
</div>
                 
<div class="row">                        
<label for="val3">
<span class="labeltxt">Question 3: How many questions can be asked in one form for example?</span>
</label>
<input id="val3" name="val3" class="calc" type="text" value="" />
</div>
                   
<div class="row">                        
<label for="val4">
<span class="labeltxt">Question 4: How many questions can be asked in one form for example?</span>
</label>
<input id="val4" name="val4" class="calc" type="text" value="" />        
</div>
                 
<div class="row">
<input class="button" type="submit" name="calculate" value="Calculate" />
</div>
</form>
                   
</body>
</html>
0
 
LVL 18

Accepted Solution

by:
Eternal_Student earned 500 total points
ID: 20280051
This better:

You can play around with the width values and styling I have just laid it out nicely.

========================
<!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>Untitled Document</title>
<style type="text/css">
.row{width:600px; clear:both; border:1px dotted #f1f1f1; margin:4px 0; padding:4px;}
label{float:left; width:250px; }
.row {width:420px; margin-left:10px; background-image:none}
.calc{float:left; margin-top:6px; }
.button{float:right; margin-right:10px;}
.clear{clear:both;}
</style>
</head>
<body>

<form action="cover_calculator_process.do" method="post">
<h3>FORM</h3>
     
<div class="row">                        
<label for="val1">
<span class="labeltxt">Question 1: How many questions can be asked in one form for example?</span>
</label>
<input id="val1" name="val1" class="calc" type="text" value="" />
<br class="clear" />
</div>
           
<div class="row">                        
<label for="val2">
<span class="labeltxt">Question2: Less text?</span>
</label>
<input id="val2" name="val2" class="calc" type="text" value="" />
<br class="clear" />
</div>
                 
<div class="row">                        
<label for="val3">
<span class="labeltxt">Question 3: How many questions can be asked in one form for example?</span>
</label>
<input id="val3" name="val3" class="calc" type="text" value="" />
<br class="clear" />
</div>
                   
<div class="row">                        
<label for="val4">
<span class="labeltxt">Question 4: How many questions can be asked in one form for example?</span>
</label>
<input id="val4" name="val4" class="calc" type="text" value="" />    
<br class="clear" />    
</div>
                 
<div class="row">
<input class="button" type="submit" name="calculate" value="Calculate" />
<br class="clear" />
</div>
</form>
                   
</body>
</html>
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20280094
Just beat me to it!
Here's another take - note that you have an error in your code where you miss closing a label and div...


<!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>Untitled Document</title>
<style type="text/css">
      .row {width:420px; margin-left:10px; position:relative; background-color:#eeeeee; margin-bottom:20px; padding:5px;}
      .row label {padding-right:160px; display:block;}
      .row input {position:absolute; right:0; top:0; width:150px; margin:5px;}
      .row .labeltxt {margin-right:10px;}
</style>
</head>
<body>
      <form action="cover_calculator_process.do" method="post">
            <h3>FORM</h3>
            
            <div class="row">
                  <label for="val1">
                        <span class="labeltxt">Question 1: XXXXXXXX XXXXXXXXX XXXXXX XXXXX XXXX XXXXX XXXXX XXX XXXXXXX</span>
                        <input id="val1" name="val1" class="calc" type="text" value="" />
                  </label>
            </div>
            <div class="row">
                  <label for="val2">
                        <span class="labeltxt">Question2: XXXXX XXXXXX XXXX XXXXXX XXXX XXXXXXXX XXXX XXXX XXXX XXXXXXXX</span>
                        <input id="val2" name="val2" class="calc" type="text" value="" />
                  </label>
            </div>
            <div class="row">
                  <label for="val3">
                        <span class="labeltxt">Question 3: XX XXXXX XXX XXXXX XXXXXX XXXXXXX</span>
                        <input id="val3" name="val3" class="calc" type="text" value="" />
                  </label>
            </div>
            <div class="row">
                  <label for="val4">
                        <span class="labeltxt">Question 4: XXXXXXXX XXX XXXXXXXX XXX XXXXXX</span>
                        <input id="val4" name="val4" class="calc" type="text" value="" />
                  </label>
            </div>
            <div class="row">
                  <input class="button" type="submit" name="calculate" value="Calculate" />
                  <div style="clear:both;">&nbsp;</div>
            </div>
      </form>
</body>
</html>
0
 
LVL 16

Expert Comment

by:rbudj
ID: 20280168
0
 

Author Comment

by:dvsuk
ID: 20280211
Thanks Eternal Student and Rouchie for your help.  Really good link rbudj - will be useful for other projects - thanks for that.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
html border input line 7 26
Can't get cursor to change 3 16
How do I Enable submit button only if listbox has items 4 35
Regular Expression needed 4 18
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question