<a href="..."> <img ...> </a>
을 사용하여 다른 페이지로 연결되는 이미지가 있습니다.<a href...>...</a> 링크를 클릭하여 제출하는 방법은 무엇입니까?
버튼 인 것처럼 게시하려면 어떻게해야합니까? <input type="submit"...>
?
<a href="..."> <img ...> </a>
을 사용하여 다른 페이지로 연결되는 이미지가 있습니다.<a href...>...</a> 링크를 클릭하여 제출하는 방법은 무엇입니까?
버튼 인 것처럼 게시하려면 어떻게해야합니까? <input type="submit"...>
?
<input type="image" name="your_image_name" src="your_image_url.png" />
: 당신이 자바 스크립트를 사용할 필요가 다음 앵커를 사용
그러면 사용자가 이미지를 클릭 한 위치의 x 및 y 좌표 인 양식을 제출할 때 your_image_name.x
및 your_image_name.y
값이 전송됩니다.
input 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>
이 <input type="image" src="...">
당신이 정말로 원하는 경우
<a href="#" onclick="document.forms['myFormName'].submit(); return false;">...</a>
무언가 like this page?
<!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>
<?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.
더 일반적인 approatch. . 여기 당신이 제출하려는 형태, 그것은에있는 양식을 제출 whitch 지정할 필요가 없습니다
<a href="#" onclick="$(this).closest('form').submit()">Submit Link</a>
좋은 답변이지만 권장 연습에 대한 우려가있을 수 있습니다 ... http://stackoverflow.com/questions/1070760/javascript-function-in-href-vs-onclick – ken
이동해야 할 때 가장 가까운()을 사용했는지 확인하십시오. DOM을 탐색 할 때 find()를 호출한다. – yardpenalty
'onclick'의 마지막에'return false; '를 추가하여 페이지의 상단으로 스크롤하는 것을 피한다. – user3409662
을 우리는 양식에이 모든 시간을 제출 버튼을 대체 :
<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>
클릭을 이미지가 양식을 제출합니다. 희망이 도움이됩니다!
이 답변은 수락 된 답변과 다른가요? 우리는 "똑같은 일이 나에게도 효과가있다"는 스타일 응답을 피하고 싶다. –
다른 URL에 다른 버튼으로 게시 할 수 있도록 추가 URL에서 post-url을 변경할 수 있습니다. 이는 'action'특성 양식을 설정하여 수행 할 수 있습니다. 여기에 jQuery를 사용하여 해당하는 코드는 다음과 같습니다
$('#[href button name]').click(function(e) {
e.preventDefault();
$('#[form name]').attr('action', 'alternateurl.php');
$('#[form name]').submit();
});
액션-속성은 이전의 jQuery 버전으로 몇 가지 문제를 가지고 있지만 최근에 당신은 갈 수있을 것입니다.
$ ('# [form name]')은 $ ('form [name = formname]')이어야합니다. # [href]는 완전히 달라야합니다. –
옛날 MS 사무실의 clippy가 Greg였습니다! – Nick