|
 |
|
อยากสร้างปุ่ม ถัดไปและย้อนกลับ(ใหม่)ให้ tabs ซึ่งเอาไปว่างตำแหน่งไหนก็ได้ (ดูโค้ดด้านในค่ะ) |
|
 |
|
|
 |
 |
|
Code (PHP)
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
div#trackbar > span {
display:inline-block;
border:2px solid white;
padding:5px;
padding-left:10px;
padding-right:10px;
background-color:gray;
color:white;
}
button {
background-color:royalblue;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color:white;
font-weight:bold;
padding:4px;
}
</style>
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
// แค่ย้ายโค้ดชุดนี้ไปไว้ตำแหน่งไหนก็ได้ครับ
///////////////////////////////////////////////////////////////////////////////////////////////////
echo "<div class=\"navbar\">";
echo "<button class=\"prev\" for=\"".( ($key<1)?1:$key )."\"><< Previous</button>";
echo "<button class=\"next\" for=\"".( (($key+2)>$maxpage)?$maxpage:($key+2))."\">Next >></button>";
echo "</div>";
///////////////////////////////////////////////////////////////////////////////////////////////////
$question[] = "1. not Toyota??";
$question[] = "2. not Thai Foods??";
$question[] = "3. not Thai's province??";
$question[] = "4. not Thai's Star??";
$choice[0][] = "a. Prius";
$choice[0][] = "b. Veron";
$choice[0][] = "c. Innova";
$choice[1][] = "a. Tomyum";
$choice[1][] = "b. Papaya pokpok";
$choice[1][] = "c. Sushi";
$choice[2][] = "a. Bangkok";
$choice[2][] = "b. Saigon";
$choice[2][] = "c. Surathanee";
$choice[3][] = "a. Nadej";
$choice[3][] = "b. Yaya";
$choice[3][] = "c. Lady Gaga";
$maxpage=count($question);
foreach($question as $key => $qdata){
$key++;
echo "<div for=\"question\" id=\"q$key\" style=\"padding-bottom:10px;\">";
echo "<div style=\"padding:5px;font-weight:bold;\">$qdata</div>";
$key--;
foreach($choice[$key] as $choicing){
echo "<div style=\"padding:15px;\"><input type=\"radio\" name=\"choice[$key]\" value=\"$choicing\" for=\"$key\">$choicing</div>";
}
echo "</div>";
}
echo "<div id=\"trackbar\">";
for($i=1; $i<=count($question); $i++){
echo "<span for=\"$i\">$i</span>";
}
echo "</div>";
?>
<script>
$("div[for=question]").hide();
$("div#q1").show();
$("input[type=radio]").change(function(){
var highlighter = parseInt($(this).attr("for")) + parseInt(1);
$("div#trackbar > span[for="+highlighter+"]").css("background-color","#00ff33");
});
$("button").click(function(){
var clicking = $(this).attr("for");
$("div[for=question]").hide();
$("div#q"+clicking).show();
});
</script>
|
ประวัติการแก้ไข 2013-03-25 08:16:55
 |
 |
 |
 |
Date :
2013-03-25 08:16:10 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไขแล้วครับ
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
div#trackbar > span {
display:inline-block;
border:2px solid white;
padding:5px;
padding-left:10px;
padding-right:10px;
background-color:gray;
color:white;
}
button {
background-color:royalblue;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color:white;
font-weight:bold;
padding:4px;
}
</style>
<?php
$question[] = "1. not Toyota??";
$question[] = "2. not Thai Foods??";
$question[] = "3. not Thai's province??";
$question[] = "4. not Thai's Star??";
$choice[0][] = "a. Prius";
$choice[0][] = "b. Veron";
$choice[0][] = "c. Innova";
$choice[1][] = "a. Tomyum";
$choice[1][] = "b. Papaya pokpok";
$choice[1][] = "c. Sushi";
$choice[2][] = "a. Bangkok";
$choice[2][] = "b. Saigon";
$choice[2][] = "c. Surathanee";
$choice[3][] = "a. Nadej";
$choice[3][] = "b. Yaya";
$choice[3][] = "c. Lady Gaga";
$maxpage=count($question);
foreach($question as $key => $qdata){
echo "<div for=\"question\" id=\"q".($key+1)."\" style=\"padding-bottom:10px;\">\n";
echo "<div class=\"navbar\">\n";
echo "<button class=\"prev\" for=\"".( ($key<1)?1:$key )."\"><< Previous</button>";
echo "<button class=\"next\" for=\"".( (($key+2)>$maxpage)?$maxpage:($key+2))."\">Next >></button>\n";
echo "</div>\n";
echo "<div style=\"padding:5px;font-weight:bold;\">$qdata</div>\n";
foreach($choice[$key] as $choicing){
echo "<div style=\"padding:15px;\"><input type=\"radio\" name=\"choice[$key]\" value=\"$choicing\" for=\"$key\">$choicing</div>\n";
}
echo "</div>\n";
}
echo "<div id=\"trackbar\">\n";
for($i=1; $i<=count($question); $i++){
echo "<span for=\"$i\">$i</span>";
}
echo "</div>\n";
?>
<script>
$("div[for=question]").hide();
$("div#q1").show();
$("input[type=radio]").change(function(){
var highlighter = parseInt($(this).attr("for")) + parseInt(1);
$("div#trackbar > span[for="+highlighter+"]").css("background-color","#00ff33");
});
$("button").click(function(){
var clicking = $(this).attr("for");
$("div[for=question]").hide();
$("div#q"+clicking).show();
});
</script>
|
 |
 |
 |
 |
Date :
2013-03-27 01:29:04 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|