我们已经在PHP中开发了像Google Forms这样的表单创建模块..所有工作正常,同时添加&创建表单..
对于编辑,我们使用了模式弹出窗口,我们使用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 for show&amp;在Main.php
中通过模态popu调用它时,div的隐藏功能无法正常工作答案 0 :(得分:0)
完成...
问题已使用java脚本冲突解决