【发布时间】:2020-07-09 04:15:22
【问题描述】:
我想请教您的建议,或者如果您有更好的建议。这是我网站的问题。我不是 AJAX 和/或 Javascript 方面的专家。这是场景:
在我的模式中,有一个表单有两个输入:
1.要生成的字符串数(随机)
2。将出现在将生成的每个数据(随机字符串)中的字符串。 (这可以为空)
为了演示,我在第一个参数中输入“5”。然后“采样”到第二个。并点击“生成”按钮。
现在,每个生成的数据中带有“sample”的 5 个字符串将加载到同一个模态中。
字符串显示后。我将点击“Finalize”按钮,然后生成的字符串将被插入到我的数据库中。
这可能吗?还是我应该寻找解决方法?
modalAndform.php:
<button type="button" data-toggle="modal" data-target="#modal-generate-string">
Generate Strings
</button>
<div class="modal fade" id="modal-generate-string">
<div class="modal-dialog modal-md">
<form method="post" action="<?php echo base_url("mycontroller/generate"); ?>>
<!--- inputs --->
Quantity: <input type="number" name="quantity" required><br/>
Custom Prefix(optional): <input type="text" name="prefix">
<button type="submit">Generate</button>
<div class="for_the_result"></div>
<!--- submit/close modal --->
<button type="button" data-dismiss="modal">Cancel</button>
<button type="button">Insert Strings</button>
</form>
</div>
</div>
mycontroller.php
function generate(){
$quantity = $this->input->post('quantity');
$prefix = $this->input->post('prefix');
$myArray = array();
while($quantity){
$string1 = mdt(time());
$string2 = $string1.$prefix;
array_push($myArray, $string2);
$quantity--;
}
//I dont have any idea what to do after this. All of data in $myArray should be display back to "modalAndform.php" <div class="for_the_result"></div>;
}
【问题讨论】:
-
您应该考虑将代码添加到您的问题中,这将有助于理解问题。
-
感谢您的建议 Minnen。我已经更新了我的问题并添加了我的代码。
标签: php css codeigniter