[英]Php Submit buttons in webpages
I originally had a submit button like this 我原来有一个这样的提交按钮
<form action="<?php $self ?>" method="post" >
<input name="search" type="hidden" >
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "search">
</form>
it made this statment true 它使这句话成真
if(isset($_POST['Search'])){}
For a time all was well then i made my submit button a image 一时间一切都很好,然后我使我的提交按钮成为图像
<form action="<?php $self ?>" method="post" >
<input name="Search" type="hidden" />
<INPUT value="Search" TYPE="image" SRC="search.jpg" BORDER="0" ALT="Search">
</form>
For more time all was good untill i wanted to make this button into a text link.. 直到我想将这个按钮变成文本链接,所有的时间都还不错。
I looked on the internet and read many things where i learned that it cant be done in html but java script was needed.. so i tryed to use this code but it no longer made my statment true.. 我在互联网上看了看很多东西,我知道它无法用html完成,但是需要使用Java脚本。.所以我尝试使用此代码,但它不再使我的陈述成真。
this is the javascript submit button i found 这是我发现的javascript提交按钮
<a href='javaScript:document.FORM_NAME.submit()'>Submit</a>
My two questions to you wizards out there are 1) where do i put the value of the submit? 我对向导的两个问题是:1)我将提交值放在哪里? 2) how do i get this to replace my earlyer submit buttons? 2)我如何获取它来替换我较早的提交按钮?
Making a button into a text link is simple CSS. 将按钮变成文本链接是简单的CSS。
<input type="submit" id="submit" value="submit" class="submitbutton" />
CSS: CSS:
input.submitbutton{
margin: 0;
border: none;
background-color: transparent;
padding: 0;
}
/* Make sure the hover has the same element properties as the first, obviously changing the font colour on hover is something acceptable */
input.submitbutton:hover{
margin: 0;
border: none;
background-color: transparent;
padding: 0;
}
For starters you need to give your form a name corresponding to what's in the Javascript link (in this case, FORM_NAME
): 对于初学者,您需要为表单指定一个与Javascript链接中的名称相对应的名称(在本例中为FORM_NAME
):
<form name="FORM_NAME" action="<?php $self ?>" method="post" >
<input name="search" type="hidden" />
<a href='javaScript:document.FORM_NAME.submit()'>Submit</a>
</form>
Then on the page that checks the form, you need to check for $_POST['search']
, which comes from the input
. 然后,在检查表单的页面上,您需要检查$_POST['search']
,它来自input
。 I don't think case matters, but it makes sense to always check using the same string anyway. 我认为大小写无关紧要,但是总要使用相同的字符串进行检查是有意义的。
I'm not 100% sure what this form is meant to do since it doesn't seem to submit anything, don't you want to use a text input so the user can search for something? 我不确定该表单的用途是什么,因为它似乎没有提交任何内容,因此我不是100%知道吗?您是否不想使用文本输入,以便用户可以搜索内容?
If you want an image as a submit button? 如果要将图像用作提交按钮? Why not use the button element 为什么不使用按钮元素
<button name="search" value="search" type="submit">
Send<img src="/icons/wow.gif" alt="wow" /></button>
see: http://www.w3.org/TR/html401/interact/forms.html#h-17.5 参见: http : //www.w3.org/TR/html401/interact/forms.html#h-17.5
Just out of curiosity, how will users without javascript enabled submit the form? 出于好奇,未启用JavaScript的用户将如何提交表单?
How about using CSS to style submit input to look like a text rather than a button? 如何使用CSS设置提交输入的样式,使其看起来像文本而不是按钮?
examples here: http://cssm.wordpress.com/2006/10/01/how-do-i-make-a-submit-button-look-like-text/ http://forums.digitalpoint.com/showthread.php?t=403667 此处的示例: http : //cssm.wordpress.com/2006/10/01/how-do-i-make-a-submit-button-look-like-text/ http://forums.digitalpoint.com/showthread .php?t = 403667
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.