询问你是否确定要提交? JavaScript的? [英] Ask if you are sure you want to submit? JavaScript?
问题描述
//其他的东西在这里 - 不重要
echo< td> ;< form action ='redeem.php'method ='post'id ='form'>< input type ='hidden'name ='redeem'value ='1'/>< input type ='隐藏'name ='id'value ='。 $ id。 '/>< input type ='submit'name ='Redeem'value ='Redeem'>< / form>< / td>;
} else {
echo'< td>< form action ='redeem.php'method ='post'id ='form'>< input type ='hidden'name =' redeem'value ='0'/>< input type ='hidden'name ='id'value ='。 $ id。 '/>< input type ='submit'name ='Un-Redeem'value ='Un-Redeem'>< / form>< / td>;
//其他东西在这里 - 不重要
我想改变它以便当您按下:
a)'兑换'提交按钮时,它会提醒您说:您确定要兑换吗?
b)'Un-Redeem'提交按钮它会提醒你说:你确定要Un-Redeem吗?
我尝试了其中的几个,其中包括ONCLICK上的提交但没有工作..我相信这是因为我在ECHO中,我不得不删除()引号停止发生功能。
任何人都知道另一种方式我可以做到这一点?
这是解决方案:
//其他东西在这里 - 不重要
echo< td>< form action ='redeem.php'method ='post'id =' '< input type ='hidden'name ='redeem'value ='1'/>< input type ='hidden'name ='id'value ='。$ id 。'/>
< input type ='submit'name ='Redeem'value ='Redeem'onclick =return confirm('您确定要兑换吗?')>< / form>< td>;
} else {
echo< td>< form action ='redeem.php'method ='post'id ='form'>< input type ='hidden 'name ='redeem'value ='0'/>< input type ='hidden'name ='id'value ='。$ id。'/>
< input type ='submit'name ='Un-Redeem'value ='Un-Redeem'onclick =return confirm('您确定要Un-Redeem?')>< / form>< / td>;
//其他东西在这里 - 不重要
编辑:
在这里添加了转义字符:
//其他东西这里 - 不重要
echo< td>< form action ='redeem.php'method ='post'id ='form'>< input type ='hidden'name ='redeem'value ='1'/>< input type ='hidden'name ='id'value ='。$ id。'/>
< input type ='submit'name ='Redeem'value ='Redeem'onclick = \return confirm('您确定要兑换?')\>< / form> ;< / td>;
} else {
echo'< td>< form action ='redeem.php'method ='post'id ='form'>< input type ='hidden'name ='redeem'value ='0'/>< input type ='hidden'name ='id'value ='。$ id。'/>
< input type ='submit'name ='Un-Redeem'value ='Un-Redeem'onclick = \return confirm('您确定要Un-Redeem?')\ >< / form>< / td>;
//其他东西在这里 - 不重要
I currently have this.
//other stuff up here - not important
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' /><input type='submit' name='Redeem' value='Redeem'></form></td>";
} else {
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' /><input type='submit' name='Un-Redeem' value='Un-Redeem'></form></td>";
//other stuff down here - not important
and I want to change it so that when you press:
a) the 'Redeem' SUBMIT button it alerts you saying, "Are you sure you want to Redeem?"
b) the 'Un-Redeem' SUBMIT button it alerts you saying, "Are you sure you want to Un-Redeem?"
I have tried a few of them including the ONCLICK on the submit but none worked.. and I believe that is because I have it in an ECHO and I had to remove the (") quotation marks which stopped the function from happening.
Anyone know another way I can do it?
Here is the solution :
//other stuff up here - not important
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' />
<input type='submit' name='Redeem' value='Redeem' onclick="return confirm('Are you sure you want to Redeem?')"></form></td>";
} else {
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' />
<input type='submit' name='Un-Redeem' value='Un-Redeem' onclick="return confirm('Are you sure you want to Un-Redeem?')" ></form></td>";
//other stuff down here - not important
Edit: Added escaping character in here:
//other stuff up here - not important
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' />
<input type='submit' name='Redeem' value='Redeem' onclick=\"return confirm('Are you sure you want to Redeem?')\"></form></td>";
} else {
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' />
<input type='submit' name='Un-Redeem' value='Un-Redeem' onclick=\"return confirm('Are you sure you want to Un-Redeem?')\" ></form></td>";
//other stuff down here - not important
这篇关于询问你是否确定要提交? JavaScript的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!