php 表单中的提交按钮也可以作为锚点吗?
为了在添加到购物车之前自定义产品,我使用的是带有两个提交点的PHP表单 - 上传图像&amp;附加文本。我想将页面刷新到顶部,而是要将锚点设置为接近下一步,然后将按钮用作&lt; a href =“#”#“#”&gt;&lt;/a&gt; < /代码>。
这是上传按钮代码:
<div id="virtueupl_form" style='width:100%'>
<form id="adminForm" name="adminForm" action="<?php echo JRoute::_('index.php?option=com_virtueupload&view=form'); ?>" method="post" enctype="multipart/form-data" onSubmit="return checkForm();">
<table width="130px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="70px" colspan="2" valign="top">
<label for="file"><?php echo VUOutput::_('YLANG_FORM_LBL_FILE'); ?></label> <br/>
<input name="file" type="file" />
<input id="upload_button" class="button" type="submit" value="<?php echo VUOutput::_('YLANG_UPLOAD'); ?>" onclick="this.form.status.value = '<?php echo VUOutput::_('YLANG_STAT_INITUPL'); ?> '; $('spinner').style.display = 'block'; this.form.status.style.color = '#339900'; " />
</td>
</tr>
锚定标签在哪里单击按钮后,锚标签属于在哪里将其发送到同一表格的位置?同样,在“附加文本”之后,我想避免要求用户从页面顶部向下滚动到表格的下一部分。我尝试了各种安排,但是在不真正知道我在做什么,我没有成功。
当我通过此论坛(和其他)搜索时,我只能找到简单的HTML锚结构或讨论有关使用提交按钮而不是文本链接的讨论。我想我理解锚点的工作方式,我只是无法弄清楚如何在同一按钮触发的其他事件中以形式进行配置。据我所读,看来“ onclick”命令也很重要,但我找不到有限的经验。也许我不是在搜索正确的条款?
谢谢。
In order to customize a product before adding to the cart, I'm using a php form with two submission points - upload an image & attach text. Instead of having the page refresh to the top after each button click, I want to set an anchor closer to the next step and use the button as the <a href="#"></a>
.
This is the upload button code:
<div id="virtueupl_form" style='width:100%'>
<form id="adminForm" name="adminForm" action="<?php echo JRoute::_('index.php?option=com_virtueupload&view=form'); ?>" method="post" enctype="multipart/form-data" onSubmit="return checkForm();">
<table width="130px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="70px" colspan="2" valign="top">
<label for="file"><?php echo VUOutput::_('YLANG_FORM_LBL_FILE'); ?></label> <br/>
<input name="file" type="file" />
<input id="upload_button" class="button" type="submit" value="<?php echo VUOutput::_('YLANG_UPLOAD'); ?>" onclick="this.form.status.value = '<?php echo VUOutput::_('YLANG_STAT_INITUPL'); ?> '; $('spinner').style.display = 'block'; this.form.status.style.color = '#339900'; " />
</td>
</tr>
Where does the anchor tag belong to send it to a place further down the same form once the button is clicked? Similarly, after 'attaching text' I would like to avoid requiring the user to scroll down from the top of the page to the next part of the form. I have tried various arrangements but without really knowing what I'm doing, I haven't been successful.
When I searched through this forum (and others) I was only able to find the simple html anchor structure or discussions about using a submit button versus a text link. I think I understand how anchors work, I just can't figure out how to configure it within a form with other events triggered by the same button. From what I read it seems that the 'onclick' command is also important but I couldn't find anything obvious for my limited experience. Perhaps I am not searching the right terms?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提交按钮是特殊按钮,将自动触发表单的
提交
事件。使用任何其他方式,您必须手动从JavaScript触发事件。例如,使用锚点,您
通常会拥有类似的东西,使用提交按钮是可取的,而不是任何其他方法,因为它不取决于JavaScript,并且默认情况下是本地定位于浏览器网站的。实际上,您可以使用一个提交按钮,然后将其与CSS进行样式。并且在同一形式中拥有多个提交按钮也很好。
另外,请注意,有些示例会触发事件来自
> href
属性,但是我不建议使用此IMO,因为它会将JavaScript暴露于用户的锚点提示(当鼠标悬停的链接时,您可以看到它的内容是href 页面底部的属性)。
最后,您几乎可以使用任何元素来触发表单提交事件!例如,请考虑(使用jQuery):
Submit buttons are special buttons that will automatically trigger the
submit
event of a form. Using any other way, you have to manually trigger the event from Javascript.For example, using an anchor, you would have something like
Usually, using a submit button is preferable as opposed to any other method as it does not depend on Javascript and is by default localized to the browser's locale. You can actually have a submit button and simply style it with CSS. And having more than one submit buttons within a same form is just fine as well.
Also, note that some examples will trigger the event from the
href
attribute, but I do not recommend this IMO, as it exposes Javascript to the user's anchor hint (when the mouse hover's a link, you can see the content of it'shref
attribute at the bottom of the page).Finally, you may use just about any element to trigger a form submit event! Consider this for example (using jQuery) :