我是新來的PHP和工作添加房間行有兩個文本框,每按一下標題添加房間按鈕。 請教我如何着手。對於每個增加的房間行,應該有單個提交按鈕。如何在每個按鈕點擊單行上添加文本框?
防爆 - :
Room 1 textbox1 textbox2
Room 2 textbox1 textbox2
Button(Add room)
Button(Submit)
我是新來的PHP和工作添加房間行有兩個文本框,每按一下標題添加房間按鈕。 請教我如何着手。對於每個增加的房間行,應該有單個提交按鈕。如何在每個按鈕點擊單行上添加文本框?
防爆 - :
Room 1 textbox1 textbox2
Room 2 textbox1 textbox2
Button(Add room)
Button(Submit)
你必須創建HTML表單獲得信息。
http://www.w3schools.com/html/html_forms.asp
您應該在form action中添加文件名來引用.php文件。
<form action = "rooms.php">
您應該確定形成方法(POST或GET)
http://www.w3schools.com/tags/ref_httpmethods.asp
最後,創建了PHP文件和$ _GET或$ _POST表單輸入名字和你能理解什麼房在哪個變量中。
請詳細說明你的意見。我無法添加窗體上的按鈕點擊相同的頁面也怕存儲他們varible – user3675069 2014-10-17 09:09:43
你可能應該使用jQuery來做到這一點。 喜歡的東西:
<script>
$(function(){
$("button#addRoom").click(function(){
$("div#rooms").append("<div class='room'>Demo</div><textarea class='roomText'></textarea>");
})
})
</script>
然後你的HTML這樣的:
<div id="rooms">
<div class='room'></div>
<textarea class='roomText'></textarea>
</div>
<button id="addRoom">Add a new room</button>
<button type="submit">Submit</button>
我沒有測試過這一點,所以你可能要做出一些改變,使其工作。不要忘記在這一個上導入jQuery。
這裏是我使用最多的時間相同的代碼:
<script>
$(document).ready(function(){
$('.multi-field-wrapper').each(function() {
var $wrapper = $('.multi-fields', this);
$(".add-field", $(this)).click(function(e) {
$('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper).find('input').val('').focus();
});
$('.multi-field .remove-field', $wrapper).click(function() {
if ($('.multi-field', $wrapper).length > 1)
$(this).parent('.multi-field').remove();
});
});
});
</script>
HTML
<div class="multi-field-wrapper">
<div class="multi-fields">
<div class="multi-field">
<input name="file[]" id="text" class="emcee_field1" style="float:none; margin-left:15px;" value="<?php echo $video[$rj]; ?>" type="text" required/>
<input type="text" name="video_de[]" class="emcee_field1" value="<?php echo $video_description[$rj]; ?>" style="float:none; min-width:200px; min-height:20px;" required>
<img src="../images/cross_icon.png" class="remove-field"/>
</div>
</div>
<button type="button" class="add-field">Add Video</button>
</div>
我希望這會幫助你。 謝謝&保留編碼:)
請讓我清楚..我無法開始.. – user3675069 2014-10-17 09:27:58
在這裏你去http://jsfiddle.net/aaki/hMJEy/1/ – 2014-10-17 10:40:14
我在jquery的幫助下完成了感謝 – user3675069 2014-10-18 07:08:19
使用jquery或javascript進行此任務。學習JS。 – 2014-10-16 11:51:02