나는 내 친구와 나에게 사이트를 만들고 있습니다. 주요 기능은 누가 더 나은지 묻는 설문 조사입니다. 입력 유형이 라디오로 설정되어 있습니다. 설문 조사에서 클릭 만하는 대신 내 맞춤 이미지를 버튼으로 사용할 수 있는지 알고 싶습니다. 하나의 버튼에는 내 이름이 있고, 다른 버튼에는 내 친구의 이름이 있습니다. PHP 폴링 용 사용자 정의 버튼
여기에 현재 코드입니다 : 물론<html>
<head>
<title>Home</title>
<meta name="author" content="My Name">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" rev="stylesheet" href="divs.css"
type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" rev="stylesheet" href="styles.css"
type="text/css" media="screen" charset="utf-8" />
<script>
function getVote(int) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("poll").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","poll_vote.php?vote="+int,true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="all"> <!-- Start All Div -->
<div id="header"> <!-- Start Header Div -->
<embed width="800" height="100px" src="../Media/Banner/banner.swf">
<embed width="800" height="50px" src="../Media/DD Menu/ddmenu3.swf">
</div> <!-- End Header Div -->
<div id="main"> <!-- Start Main Div -->
<div id="poll">
<h3>Me or Friend?</h3>
<form>
Me:
<input type="radio" name="vote" value="0" onclick="getVote(this.value)">
<br>
Friend:
<input type="radio" name="vote" value="1" onclick="getVote(this.value)">
</form>
</div>
</div> <!-- End Main Div -->
<div id="footer"> <!-- Start Footer Div -->
<p class="footer">© Copyright,
2014 - <script language="javascript" type="text/javascript">
var today = new Date()
var year = today.getFullYear()
document.write(year)
</script></p>
</div> <!-- End Footer Div -->
</div> <!-- End All Div -->
</body>
</html>
<?php
$vote = $_REQUEST['vote'];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0) {
$yes = $yes + 1;
}
if ($vote == 1) {
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Result:</h2>
<table>
<tr>
<td>Yes:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($yes/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($yes/($no+$yes),2)); ?>%
</td>
</tr>
<tr>
<td>No:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($no/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($no/($no+$yes),2)); ?>%
</td>
</tr>
</table>
': before' 의사 요소를 살펴보십시오. 정상적인 서클 위에 무언가를 배치 할 수 있습니다. – David