Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Allineamento

  1. #1

    Allineamento

    Ho un problema con l'allineamento di alcuni campi.

    Utilizzo dei table... e arrivato al punto dove inserisco una piccola funzion javascript che fa aggiungere + campi, creo un'altra voce che vorrei fosse allineata con le altre... ma non riesco perché da quanto ho capito prende la lunghezza del TD di una voce precedente e adatta tutta la tabella di conseguenza.

    Questo è il mio codice:

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>aggiungi / rimuovi campi input</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    var num=1;
    
    </script>
    </head>
    <body>
    
    	<table align ="center">
    			
    			<td></td>
    			<td></td>
    			<td></td>
    			<td>Di chi?</td>		
    			<td>Nome e cognome</td>
    			</tr>
    
    
    			<tr>
    			<td>2) 123456 1 123456789123 1234567891234 12345 1234567</td>
    			<td><input name="aaaaaaaa" maxLength="50"  size=10>  </td>
    			
    			<td><input name="Commento 2)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"></td>
    			</tr>
    
    	
    			<tr>
    			<td>8) 12345678 123456789</td>
    			<td><input name="bbbbbbbb" maxLength="50"  size=10> </td>
    			
    			<td><input name="Commento 8)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"> </td>
    
    			<td><select name="abcT" size="1" maxLength="50">
      			<option selected><? echo($_GET["abc"]);?> </option>
               		<option>Lupin</option>
               		<option>Jighen</option>
               		<option>Altre persone</option>
    			</select>
    			</td>
    
    			<td><input name="ccccccccc" maxLength="30" size=35>  </td>
    			</tr>
    
    
    			
    
    			<tr>
    			<td>9) 123456 1234567</td>
    			<td><input name="ddddddd" maxLength="50" size=10></td>
    			
    
    			<td><input name="Commento 9)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"></td>
    
    			<td><input name="Aggiungi" type="button" value="Aggiungi altri" onclick="accoda()"></td><td><input type="button" value="rimuovi" onclick="rimuovi()"></td>
    			
    			</tr>
    			<form name="modulo">
    
    			<table align="center" id="tabella">
    			<tbody>
    			<tr>
    			<td></td>
    
    			</tr>
    			</tbody>
    			</table>			
    			</form>
    			
    			<table align="center">
    			<tr>
    			<td>10) 123456 12345 12345678912</td>
    			<td><input name="eeeeeeee" maxLength="50"  size=10> </td>
    			
    
    			<td><input name="Commento 10)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"> </td>
    
    			<td><input name="Aggiungi" type="button" value="Aggiungi altri" onclick="accoda()"> </td><td width=15%><input type="button" value="rimuovi" onclick="rimuovi()"></td>
    
    			</tr>	
    
    </table>
    
    
    </body>
    </html>
    non fate troppo caso ai numeri... era per dare un'idea della lunghezza del TD.
    Usare i table è sbagliato? Devo per caso usare div? Non ho mai provato e non saprei da dove partire... qualcuno mi può aiutare?

    Grazie

  2. #2

    up...

  3. #3
    Scusate se uppo ancora... ma non riesco a risolvere questo problema di allineamento... posto un codice più "semplice"... qlc mi può aiutare?

    codice:
    
    <html>
    	<head>
    	
    
    
    	<script language="javascript" type="text/javascript">
    	
    
    var num=1;
    
    function accoda(){
    	if(document.createElement && document.getElementById && document.getElementsByTagName) {
    		// crea elementi
    		var oTr=document.createElement("TR");
    		var oTd1=document.createElement("TD");
    		var oTd2=document.createElement("TD");
    		var oTd3=document.createElement("TD");
    		var oTd4=document.createElement("TD");
    		var oField=document.createElement("INPUT");
    		var oText=document.createTextNode(""+num);
    
    		// setta attributi
      		oField.setAttribute("type","text");
    		oField.setAttribute("name","testo"+num);
    		oField.setAttribute("size","10");
    
    		// appendi al relativo padre
    		oTd1.appendChild(oField);
    		oTd2.appendChild(oText);
    		oTr.appendChild(oTd1);
    		oTr.appendChild(oTd2);
    		document.getElementById('tabella').getElementsByTagName('TBODY')[0].appendChild(oTr);
    
    		// incrementa variabile globale
    		num++
    	}
    }
    
    function rimuovi(){
    	if(document.removeChild && document.getElementById && document.getElementsByTagName) {
    		// se non e' la prima riga
    		if(num>1){
    			// riferimento al tbody
    			var tb=document.getElementById('tabella').getElementsByTagName('TBODY')[0];
    			// riferimento all' ultimo TR
    			var lastTr=tb.getElementsByTagName('TR')[(tb.getElementsByTagName('TR').length)-1]
    			// rimuovi
    			tb.removeChild(lastTr);
    			// decrementa variabile globale
    			num--
    		}
    	}
    }
    //-->
    
    	</script>
    	
    	</head>
    
    	<body>
    
    
    		<table align ="center">
    			
    
    	
    			<tr>
    			<td>1) </td>
    			<td><input name="bla1" maxLength="50"  size=10> </td>
    			
    			<td><input name="Commento 1)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"> </td>
    
    			<td><select name="bla1" size="1" maxLength="50">
      			<option selected><? echo($_GET["SostPropLT"]);?> </option>
               		<option>1</option>
               		<option>2</option>
               		<option>3</option>
    			</select>
    			</td>
    
    			<td><input name="bla2x" maxLength="30" size=35>  </td>
    			</tr>
    
    
    			
    
    			<tr>
    			<td>2) </td>
    			<td><input name="DebPriv" maxLength="50" size=10></td>
    			
    
    			<td><input name="Commento 2)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"></td>
    
    			<td><input name="Aggiungi" type="button" value="Aggiungi altri" onclick="accoda()"></td><td><input type="button" value="rimuovi" onclick="rimuovi()"></td>
    			
    			</tr>
    
    
    			<form name="modulo">
    
    			<table align="center" id="tabella">
    			<tbody>
    			<tr>
    			<td></td>
    
    			</tr>
    			</tbody>
    			</table>			
    			</form>
    			
    			<table align="center">
    			<tr>
    			<td>10) </td>
    			<td><input name="bla3" maxLength="50"  size=10> </td>
    			
    
    			<td><input name="Commento 10)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"> </td>
    
    			<td><input name="Aggiungi" type="button" value="Aggiungi altri" onclick="accoda()"> </td><td><input type="button" value="rimuovi" onclick="rimuovi()"></td>
    
    			</tr>	
    
    
    
    			<tr>
    			<td>11)</td>
    			<td><input name="bla3" maxLength="50" size=10> </td>
    			
    			<td><input name="Commento 11)" type="button" value="*" onClick="show_hide(this); this.style.color='red'"> </td>
    			<td align="center"><input id="Aggiungi_P" name="Aggiungi_P" type="submit" value="Aggiungi altre"> </td>
    			</tr>	
    
    
    
    
    
    		</table>
    
    
    
    
    
    
    
    	</body>
    
    </html>
    Avrei la necessità di allineare 10) e 11) come 1) e 2)...

    Grazie

  4. #4
    Proprio nessuna idea? Scusate questa è l'ultima volta che uppo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.