如何使用CSS按钮在表单中发布方法?

发布于 2024-12-11 20:36:54 字数 1302 浏览 0 评论 0原文

我喜欢这篇文章 "如何使用 jQuery 创建类似 Skype 的按钮”

但是评论列表已经关闭,所以我需要你们的帮助!

如何使用提交方法将此代码写入表单?

<a class="button" href="#"> 
<img src="*.png" alt="" />Add to cart</a>

这是我的表单示例,我希望在其中插入 css 按钮:

<form action="http://ww6.aitsafe.com/cf/addmulti.cfm" name="mal" method="post">
<input type="hidden" name="userid" value="">
<input type="hidden" name="return" value="">    
<input type="hidden" name="nocart">
<input type="hidden" name="qty1" value="1">
<input type="hidden" name="product1" value="">
<input type="hidden" name="price1" value="150.00">

<input type=submit value="Add to Cart" onclick="alert('Added to cart\n\nThis page will refresh');">

更新...耶嘿! :)

感谢 PCALCAO 提供的链接 如何最好地制作链接提交表格

在那里我发现克里斯的回答非常有帮助&现在它正在工作......

正确答案:

<a class="button" href="#" onclick="document.mal.submit(); return false;"> 
<img src="*.png" alt="" />Add to cart</a>

:)

I love this article
"How to create Skype-like buttons using jQuery"

But the comment list is already closed so I need your help guys!

How to make this code to a form using submit method?

<a class="button" href="#"> 
<img src="*.png" alt="" />Add to cart</a>

This is the sample of my form where I want the css button to be inserted:

<form action="http://ww6.aitsafe.com/cf/addmulti.cfm" name="mal" method="post">
<input type="hidden" name="userid" value="">
<input type="hidden" name="return" value="">    
<input type="hidden" name="nocart">
<input type="hidden" name="qty1" value="1">
<input type="hidden" name="product1" value="">
<input type="hidden" name="price1" value="150.00">

<input type=submit value="Add to Cart" onclick="alert('Added to cart\n\nThis page will refresh');">

update... yehey! :)

Thank You to PCALCAO for the link How best to make a link submit a form

There I found the answer of CHRIS to be very helfpful & now it's working...

Correct answer:

<a class="button" href="#" onclick="document.mal.submit(); return false;"> 
<img src="*.png" alt="" />Add to cart</a>

:)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

牵你的手,一向走下去 2024-12-18 20:36:54

我不知道你想在那里做什么......但是!

这里是:
http://www.w3schools.com/html/html_forms.asp

阅读此内容,然后您将了解一些有关表单和提交按钮的知识。

当您弄清楚简单的 html 部分时,开始考虑 CSS 和 JQuery。

-编辑-
你真的应该重新阅读那篇文章!
对于初学者来说,它是:

<a class="button" href="#">
<img src="button.png" alt="" />Send info</a>
or <a href="#">cancel</a>

而不是:

<class="button" a href="#"> 
<img src="*.png" alt="" />Add to cart</a>    

“class”是 HTML 元素的属性,而不是元素本身。这里的元素是“a”(锚点)。

I have no idea what you're trying to do there... but!

Here it is:
http://www.w3schools.com/html/html_forms.asp

Read this, and you'll learn a bit about forms and submit buttons.

When you figure the simple html part out, start thinking about the CSS and JQuery.

-EDIT-
You should really re-read that article!
For starters, it's:

<a class="button" href="#">
<img src="button.png" alt="" />Send info</a>
or <a href="#">cancel</a>

and not:

<class="button" a href="#"> 
<img src="*.png" alt="" />Add to cart</a>    

"class" is an attribute of an HTML element, not an element by itself. The element here is "a" (anchor).

奈何桥上唱咆哮 2024-12-18 20:36:54

我没有正确地理解你,但是如果你想设置一个图像作为提交按钮背景,请将CSS修改为:

.button input[type="submit"]
    {
        background:url(*.png);
        color:#fff;
        width:80px;
    }

并且html表单将是:

<div class="button">
<input type="submit" value="SUBMIT" />
</div>

I did not get you properly,but if you want to set an image as the submit button background,the modify the css to :

.button input[type="submit"]
    {
        background:url(*.png);
        color:#fff;
        width:80px;
    }

and the html form will be :

<div class="button">
<input type="submit" value="SUBMIT" />
</div>
你又不是我 2024-12-18 20:36:54

我不知道你上面的代码是什么。
我认为你应该看看 HTML 表单。

演示代码:

<form method="get" action="post.php">
<input type="text" name="text">
<input type="submit" name="submit" value="Submit!">
</form>

I don't know what is your code ment to be above.
I think you should look at HTML forms.

demo code:

<form method="get" action="post.php">
<input type="text" name="text">
<input type="submit" name="submit" value="Submit!">
</form>
多像笑话 2024-12-18 20:36:54

如果您想在 sbmit 按钮上应用 css,请尝试下面的 jquery 代码:

function setCss()
{
$(document).ready (function() {

$(":input[type=submit]" ).addClass("bigbutton");
 });
}

setCss();

使用下面的按钮样式:

.button{
         border:0;
     background:url(images/yourimage.gif);
     font-family:Verdana, Arial, Helvetica, sans-serif;
     font-size:12px;
     text-align:center;
     color:#FFFFFF;
     cursor:pointer;
     height:22px;
     width:80px;
     }

它将适用于所有浏览器。

如果你想要动画,那么使用 jquery 函数更改悬停时的图像/样式:

$( ":input[type=submit]" ).css( {"background": 'no-repeat url("'+baseurl+'/public/images/blue_btn1.gif")', "color": "#ffffff","width":"80px","height":"25px", "font-weight": "bold","font-family":"Verdana, Arial, Helvetica, sans-serif","font-size":"12px","background":"none","border":"0"} );

Try below jquery code if you want to apply css on sbmit button:

function setCss()
{
$(document).ready (function() {

$(":input[type=submit]" ).addClass("bigbutton");
 });
}

setCss();

Use below Style for button :

.button{
         border:0;
     background:url(images/yourimage.gif);
     font-family:Verdana, Arial, Helvetica, sans-serif;
     font-size:12px;
     text-align:center;
     color:#FFFFFF;
     cursor:pointer;
     height:22px;
     width:80px;
     }

It will work for all browsers.

if you want animate then change image/style on hover using jquery function :

$( ":input[type=submit]" ).css( {"background": 'no-repeat url("'+baseurl+'/public/images/blue_btn1.gif")', "color": "#ffffff","width":"80px","height":"25px", "font-weight": "bold","font-family":"Verdana, Arial, Helvetica, sans-serif","font-size":"12px","background":"none","border":"0"} );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文