我使用< a href =" ...">获得了一个图像链接到另一个页面< img ...> < / A>

如何制作帖子,如果它是一个按钮< input type =" submit" ...>

有帮助吗?

解决方案

<input type="image" name="your_image_name" src="your_image_url.png" />

这将在提交表单时发送 your_image_name.x your_image_name.y 值,这是用户单击图像的位置的x和y坐标

其他提示

使用 JQuery 库进行更通用的批准最近的()和提交()按钮。 在这里,您不必指定要提交的表格,提交它所在的表格。

<a href="#" onclick="$(this).closest('form').submit()">Submit Link</a>

看起来你正在尝试使用图片提交表单......在这种情况下使用 &lt; input type =&quot; image&quot; SRC =&QUOT; ...&QUOT;&GT;

如果你真的想使用锚,那么你必须使用javascript:

&lt; a href =&quot;#&quot;的onclick = QUOT; document.forms [ 'myFormName']提交(); return false;&quot;&gt; ...&lt; / a&gt;

输入type = image 将为您完成。

未经测试/可能更好:

<form action="page-you're-submitting-to.html" method="POST">
    <a href="#" onclick="document.forms[0].submit();return false;"><img src="whatever.jpg" /></a>
</form>
 <html>

 <?php

 echo <*>POST['c']." | ".<*>POST['d']." | ".<*>POST['e'];

 ?>

 <form action="test.php" method="POST">
      <input type="hidden" name="c" value="toto98">
      <input type="hidden" name="d" value="toto97">
      <input type="hidden" name="e" value="toto aaaaaaaaaaaaaaaaaaaa">

      <a href="" onclick="document.forms[0].submit();return false;">Click</a> 
 </form>

</html>


So easy.




So easy.

这可能是一个方便的补充,可以从额外按钮更改post-url,以便您可以使用不同的按钮发布到不同的URL。这可以通过设置表单'action'属性来实现。以下是使用jQuery时的代码:

$('#[href button name]').click(function(e) {
    e.preventDefault();
    $('#[form name]').attr('action', 'alternateurl.php');
    $('#[form name]').submit();
});

action-attribute在旧的jQuery版本中存在一些问题,但是最新版本你会很高兴。

喜欢这个页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>BSO Communication</title>

<style type="text/css">
.submit {
    border : 0;
    background : url(ok.gif) left top no-repeat;
    height : 24px;
    width : 24px;
    cursor : pointer;
    text-indent : -9999px;
}
html:first-child .submit {
    padding-left : 1000px;
}
</style>
<!--[if IE]>
<style type="text/css">
.submit {
    text-indent : 0;
    color : expression(this.value = '');
}
</style>
<![endif]-->
</head>

<body>
    <h1>Display input submit as image with CSS</h1>

    <p>Take a look at <a href="/2007/07/26/afficher-un-input-submit-comme-une-image/">the related article</a> (in french).</p>
    <form action="" method="get">
        <fieldset>
            <legend>Some form</legend>
            <p class="field">
                <label for="input">Some value</label>

                <input type="text" id="input" name="value" />
                <input type="submit" class="submit" />
            </p>
        </fieldset>
    </form>

    <hr />
    <p>This page is part of the <a href="http://www.bsohq.fr">BSO Communication blog</a>.</p>

</body>
</html>

不要忘记“按钮”。元素可以处理更多的HTML ...

我们一直在表单上替换提交按钮:

<form method="post" action="whatever.asp">
<input type=...n

<input type="image" name="Submit" src="/graphics/continue.gif" align="middle" border="0" alt="Continue">
</form>

单击图像会提交表单。希望有所帮助!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top