Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to allign the text box's to the top of the form

    Code:
    hi,
            I am not able to align the textfield to the top of the frame one bye one. The problem is it is showing where it is hiding..... so is it possible to allign to the top top of the form one by one. I am sending the sample code.
    
    
    Code:
    <html>
    <head>
    
    	<script type="text/javascript">
    		function changeme(field){
    			var val= field.value;
    			if( val == '1') {
    
    			   	document.getElementById("one").style.visibility="visible";
    
    			   	document.getElementById("two").style.visibility="hidden";
    			   	document.getElementById("three").style.visibility="hidden";
    			   	document.getElementById("four").style.visibility="hidden";
    			   	document.getElementById("five").style.visibility="hidden";
    
    			}else if( val == '2') {
    
    				document.getElementById("two").style.visibility="visible";
    
    				document.getElementById("one").style.visibility="hidden";
    				document.getElementById("three").style.visibility="hidden";
    				document.getElementById("four").style.visibility="hidden";
    				document.getElementById("five").style.visibility="hidden";
    
    			} else if( val == '3') {
    				document.getElementById("three").style.visibility="visible";
    
    				document.getElementById("one").style.visibility="hidden";
    				document.getElementById("two").style.visibility="hidden";
    				document.getElementById("four").style.visibility="hidden";
    				document.getElementById("five").style.visibility="hidden";
    
    			}else if( val == '4') {
    				document.getElementById("four").style.visibility="visible";
    
    				document.getElementById("one").style.visibility="hidden";
    				document.getElementById("two").style.visibility="hidden";
    				document.getElementById("three").style.visibility="hidden";
    				document.getElementById("five").style.visibility="hidden";
    
    			}else if( val == '5') {
    				document.getElementById("five").style.visibility="visible";
    
    				document.getElementById("one").style.visibility="hidden";
    				document.getElementById("two").style.visibility="hidden";
    				document.getElementById("three").style.visibility="hidden";
    				document.getElementById("four").style.visibility="hidden";
    
    			}
    
    		}
    
    	</script>
    
    </head>
    <body>
    <form name="myform">
    
    <table width="100%"  border="0" cellpadding="2" cellspacing="2">
    		<tr id ="main" >
    		    <td> main<input type="text"></td>
    		</tr>
    
            <tr id="one" style="visibility:hidden">
    	        <td>NAME: <input type="text">
    	        NAME1: <input type="text"></td>
    	    </tr>
    	    <tr  id="two" style="visibility:hidden">
    	        <td>NO :<input type="text">
    	        NO1 :<input type="text"></td>
    	    </tr>
    	    <tr  id="three" style="visibility:hidden">
    	        <td>DESIG: <input type="text">
    	        DESIG1: <input type="text"></td>
    	    </tr>
    	    <tr id="four" style="visibility:hidden" >
    	        <td>ADDR <input type="text">
    	        ADDR1 <input type="text"></td>
    	    </tr>
    	    <tr id="five" style="visibility:hidden">
    	    	<td>PHONE NAME <input type="text">
    	    	PHONE NAME1 <input type="text"></td>
    	    </tr>
    
    </table>
    
    <select value="please select" name="selBox" onChange="changeme(this)">
       <option value="1">1</option>
       <option value="2">2</option>
       <option value="3">3</option>
       <option value="4">4</option>
    </select>
    </form>
    </body>
    </html>
    thx, HANM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Instead of table, use separate ,<div></div> to enclose your input fields in each row.

    put style like
    Code:
    <div id="tow" style="display:none"></div>
    to all the divs you want to hide.

    And in the JS, use
    Code:
    document.getElementById("one").style.display="block";
    and
    Code:
    document.getElementById("two").style.display="none";
    Hope this may help!
    Last edited by abduraooft; 08-23-2007 at 09:04 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •