Solved

Help with formatting a web form (HTML)

Posted on 2007-11-14
5
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

688 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