Yanıt Jquery Add Table Row (Session)

Tüm Yanıtlar

  • 18 Nisan 2012 Çarşamba 06:35
    Moderatör
     
     Yanıt Kod İçerir

    jquery ile yapılmış, bence jquery ile rahatça yapılır. Aşağıda basitçe bir örnek yaptım;
    Not: Çalışması için jquery library'in dahil edilmiş olması gerekir

    <script type="text/javascript">
    		function AddLine(t, p, q) {
    			var tr = document.createElement("TR");
    			$(tr).css('display', 'none');
    			var c1 = document.createElement("TD");
    			var c2 = document.createElement("TD");
    			var c3 = document.createElement("TD");
    			var c4 = document.createElement("TD");
    			$(c1).html(t);
    			$(c2).html(p);
    			$(c3).html(q);
    			$(c4).html(p*q);
    			$(tr).append(c1).append(c2).append(c3).append(c4);
    			$('#lines').append(tr);
    			$(tr).fadeIn('slow');
    			return false;
    		}
    	</script>
    	<fieldset style="border-radius: 8px;">
    		<legend>Sipariş Tablosu</legend>
    		<table id="orderTable" border="0" cellpadding="4" cellspacing="0" style="width: 600px;">
    			<tbody id="lines">
    				<tr>
    					<th>
    						Ürün
    					</th>
    					<th>
    						Fiyat
    					</th>
    					<th>
    						Miktar
    					</th>
    					<th>
    						Tutar
    					</th>
    				</tr>
    			</tbody>
    			<tfoot>
    				<tr>
    					<td>
    						<select id="product">
    							<option selected="selected" value="Kalem">Kalem</option>
    							<option value="Defter">Defter</option>
    							<option value="Silgi">Silgi</option>
    							<option value="Cetvel">Cetvel</option>
    							<option value="Pergel">Pergel</option>
    						</select>
    					</td>
    					<td>
    						<input type="text" id="price" />
    					</td>
    					<td>
    						<input type="text" id="quantity" />
    					</td>
    					<td>
    						<button onclick="return AddLine($('#product').val(), $('#price').val(), $('#quantity').val());">
    							Ekle</button>
    					</td>
    				</tr>
    			</tfoot>
    		</table>
    	</fieldset>


    e-mail: onay[nokta]yalciner[at]hotmail[nokta]com
    MCC