Solved

Help with formatting a web form (HTML)

Posted on 2007-11-14
5
196 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

773 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