我的.php文件中有一个提交按钮,但我想创建另一个提交并允许再次填写表单。 例如:我正在添加一个新产品,我希望在不关闭表单的情况下添加很多产品。
因此,对于提交按钮,我有这个代码:
<div id="novoServico<?= $sub->getIdSubcategoria()?>" class="modalDialog">
<div>
<a href="#secao_servicos" title="Close" class="close">X</a>
<?php $data['idSubcategoria'] = $sub->getIdSubcategoria();
$data['idEmpresa'] = $empresa->getIdEmpresa();
$this->load->view("servico_add_view",$data); ?>
</div>
</div>
使用此代码调用文件
$data = array(
'type' => 'submit',
'id' => 'submit',
'class' => 'button',
'value' => 'Inserir'
);
echo form_label('<span> </span>','submit');
echo form_input($data);
有谁能告诉我什么功能或什么开始创建'提交并再次添加'按钮?
谢谢!
答案 0 :(得分:0)
我认为实现这一点的最佳方法是使用AJAX。特别是,我更喜欢jQuery + AJAX,因为它简化了很多程序并且你编写的代码少得多。
因此,为了澄清这一点,您首先要使用jQuery库。如果您想了解Google的具体情况,那么它很简单。在此之后,可以通过AJAX以非常简单的方式发布典型的联系表单。
<强> HTML 强>
@echo off
setlocal EnableDelayedExpansion
rem Store individual elements in the array; at same time, show the menu
set i=0
for %%a in ("stream1 source" "stream1 high" "stream1 medium" "stream1 low"
"stream2 source" "stream2 high" "stream2 medium" "stream2 low") do (
set /A i+=1
set "option[!i!]=%%~a"
echo !i! = %%~a
)
set /p id="Enter ID: "
if defined option[%id%] (
set "link=twitch.tv/!option[%id%]!"
) else (
echo ..............
rem The same...
set i=0
for %%a in (source high medium low) do (
set /A i+=1
set "id[!i!]=%%a"
echo !i! = %%a
)
set /p quality="Enter ID: "
if defined id[!quality!] (
rem Note that is not possible to nest expansions this way: set hq="!id[!quality!]!"
for %%i in (!quality!) do set hq="!id[%%i]!"
) else (
set hq="source"
)
set link=twitch.tv/!id! !hq!
)
Start C:\livestreamer\livestreamer.exe %link%
echo %link%
pause
<强>的Javascript 强>
<form method="POST" action="contact.php" id="contact_form">
<br><table>
<tbody><tr><td><label>Name:</label></td><td><label>Surname:</label></td></tr>
<tr>
<td><input type="text" id="name" name="name"></td>
<td><input type="text" id="surname" name="surname"></td>
</tr>
<tr><td colspan="2"><label>Your message:</label></td></tr>
<tr><td colspan="2"><textarea id="msg" name="msg"></textarea></td></tr>
<tr><td><input type="button" id="sendbtn" onclick="sendform();" value="Send" ></td></tr>
</tbody></table>
</form>
请记住将js代码包装在函数中,以便可以使用name = document.getElementById("name").value;
surname = document.getElementById("surname").value;
msg = document.getElementById("msg").value;
$.ajax({
type: "POST",
url: "contact.php",
data: {name: name,
surname: surname,
msg: msg},
datatype: "html",
}).done(function(html) {
$(".content").html(html);
});
事件调用它。