0
我們已經開發的形式創建模塊,就像在PHP谷歌表單..一切工作正常,同時增加&創建窗體..Javascript語言,Ajax的負載頁面無法正常工作
進行編輯,我們已經使用模式彈出爲此我們加載使用Ajax內容..
MAIN.PHP
$('a[data-toggle=modal]').click(function(){
var qid = $(this).attr('data-id');
$.ajax({
type : 'post',
url : 'URL.php', // in here you should put your query
data : 'post_id='+ qid, // here you pass your id via ajax .
// in php you should use $_POST['post_id'] to get this value
success : function(r)
{
// now you can show output in your modal
$('#mymodal').show(); // put your modal id
$('.something').show().html(r);
}
});
});
URL.PHP:
$(document).on(function(){
$("#question_type2").change(function(){
alert("hello");
$("select option:selected").each(function(){
if($(this).attr("value")=="text2"){
$(".box2").hide();
$(".text2").show();
}
if($(this).attr("value")=="textarea2"){
$(".box2").hide();
$(".textarea2").show();
}
if($(this).attr("value")=="radio2"){
$(".box2").hide();
$(".radio2").show();
}
if($(this).attr("value")=="checkbox2"){
$(".box2").hide();
$(".checkbox2").show();
}
if($(this).attr("value")=="dropdown2"){
$(".box2").hide();
$(".dropdown2").show();
}
});
}).change();
});
<table id="dataTable1" class="form">
<input type="hidden" name="question_id2" value="<?php echo $qid; ?>">
<tr>
<td>Question Title</td>
<td><input type="text" name="question_title2" id="question_title2" value="<?php echo
$row_question2['question_title']; ?>"></td>
</tr>
<tr>
<td>Question Type</td>
<td>
<select id="question_type2" name="question_type2">
<option value="text2" <?php if($row_question2["question_type"]=='text'){ echo 'selected'; } ?>>Text</option>
<option value="textarea2" <?php if($row_question2["question_type"]=='textarea'){ echo 'selected'; } ?>>Paragraph</option>
<option value="radio2" name="radio" <?php if($row_question2["question_type"]=='radio'){ echo 'selected'; } ?>>Multiple Choice</option>
<option value="checkbox2" name="checkbox" <?php if($row_question2["question_type"]=='checkbox'){ echo 'selected'; } ?>>Checkbox</option>
<option value="dropdown2" <?php if($row_question2["question_type"]=='dropdown'){ echo 'selected'; } ?>>Dropdown Selection</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td>
<div class="text2 box2">
<input type="text" name="text_ans" placeholder="Their Answer" readonly>
</div>
<div class="textarea2 box2">
<textarea name="textarea_ans" rows="3" cols="20" placeholder="Their Long Answer" readonly></textarea>
</div>
<div class="radio2 box2" id="fieldadd_radio2">
<?php
$multiple_radio=explode(",",$row_question2['question_value']);
foreach($multiple_radio as $radio)
{
?>
<input type="text" name="radio[]" id="radio" value="<?php echo $radio; ?>" >
<?php
}
?>
<input type="button" value="Add More Option" onclick="mplfile_radio2()" />
</div>
<div class="checkbox2 box2" id="fieldadd_checkbox2">
<?php
$multiple_checkbox=explode(",",$row_question2['question_value']);
foreach($multiple_checkbox as $checkbox)
{
?>
<input type="text" name="checkbox[]" id="checkbox" value="<?php echo $checkbox; ?>" >
<?php
}
?>
<input type="button" value="Add More Option" onclick="mplfile_checkbox2()" />
</div>
<div class="dropdown2 box2" id="fieldadd_dropdown2">
<?php
$multiple_dropdown=explode(",",$row_question2['question_value']);
foreach($multiple_dropdown as $dropdown)
{
?>
<input type="text" name="dropdown[]" id="dropdown" value="<?php echo $dropdown; ?>" >
<?php
}
?>
<input type="button" value="Add More Option" onclick="mplfile_dropdown2()" />
</div>
</td>
</tr>
</table>
問題:
在url.php,javascript的作秀&隱藏DIV的,而在Main.php