私はphp、jquery、ajaxの初心者です。ボタンのクリック時にテキストボックスを動的に追加および削除するコードがjqueryにあります。動的に作成されたテキスト ボックスの値の値を次のページに投稿し、それらの値を次のページに表示したいと考えています。事前に感謝します。
以下のコードを貼り付けました..
リンクhttp://jsfiddle.net/NSePb/1/も確認できます
$(document).ready(function () {
var counter = 1;
$("#addButton").click(function () {
if(counter>7){
alert("Only 7 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after().html('<label>Product #'+ counter + ' : </label>' +
'<input type="text" size="22" name="product' + counter +
'" id="product' + counter + '" value=""> \n\
<label>Quantity #'+ counter + ' : </label>' +
'<input type="text" size="1" name="qty' + counter +
'" id="qty' + counter + '" value=""> \n\
<label>Rate #'+ counter + ' : </label>' +
'<input type="text" size="2" name="rates' + counter +
'" id="rates' + counter + '" value="" > \n\
<label>Total #'+ counter + ' : </label>' +
'<input type="text" size="3" name="total' + counter +
'" id="total' + counter + '" value="" > ');
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
$("#removeButton").click(function () {
if(counter==0){
alert("No more textbox to remove");
return false;
}
counter--;
$("#TextBoxDiv" + counter).remove();
});