我在這裏有一個iframe頁面。在iframe中,它將顯示多選題的所有問題。問題是我不知道如何獲取iframe中選中的單選按鈕的所有值。該按鈕位於父頁面中(我還沒有包含它)。如何獲取iframe中選中的單選按鈕的值
這是我的網頁(questions.php)的屏幕捕獲:
這是questions.php我的iframe代碼:
<div class="question-display test">
<iframe src="questions/frame.php" height="500px" width="100%">
</iframe>
</div>
這是我frame.php (顯示所有問題)
<?php
include('config.php');
$view_questions=mysql_query("SELECT * FROM questions ORDER BY RAND()");
$count=mysql_num_rows($view_questions);
$i=1;
while($row=mysql_fetch_array($view_questions))
{
?>
<div class="questions-contents text-size test" style="margin-left: 10px;">
<p align="justify"><strong><?php echo $i;?>.)</strong> <?php echo $row['QUESTION'];?></p>
</div>
<div class="answer-indent" style="margin-left: 40px; margin-bottom: 20px;">
<label class="radio">
<input type="radio" name="<?php echo $row['QUESTION_NO'];?>" value="1" data-toggle="radio">
<class="color" style="color: gray;"><?php echo $row['ANSWER_1'];?></class="color">
</label>
<label class="radio">
<input type="radio" name="<?php echo $row['QUESTION_NO'];?>" value="2" data-toggle="radio">
<class="color" style="color: gray;"><?php echo $row['ANSWER_2'];?></class="color">
</label>
<label class="radio">
<input type="radio" name="<?php echo $row['QUESTION_NO'];?>" value="3" data-toggle="radio">
<class="color" style="color: gray;"><?php echo $row['ANSWER_3'];?></class="color">
</label>
<label class="radio">
<input type="radio" name="<?php echo $row['QUESTION_NO'];?>" value="4" data-toggle="radio">
<class="color" style="color: gray;"><?php echo $row['ANSWER_4'];?></class="color">
</label>
<label class="radio" style="display: none;" >
<input type="radio" name="<?php echo $row['QUESTION_NO'];?>" value="5" data-toggle="radio" checked>
</label>
</div>
<?php
$i++; }
?>
在我讓我的frame.php從questions.php頁面插入iframe,我有一個php代碼來檢查用戶的答案(選中的單選按鈕)。
$questions = mysql_query("SELECT * FROM questions");
while($row=mysql_fetch_assoc($questions)){
if($_POST[$row['QUESTION_NO']]==$row["ANSWER"])
{
$score++;
}
elseif($_POST[$row['QUESTION_NO']]==5)
{
$unanswered++;
}
else
{
$wrong_score++;
}
}
請幫助我,我從昨天開始這樣做,但我沒有得到它。我不知道該怎麼做。
什麼是對包括通過IFRAME形式的原因是什麼? – 2014-11-05 06:35:55
有一個滾動條,以防止長頁面(頁面高度)。 – Ejardy 2014-11-05 06:37:26
你可以用div容器做這個,並通過CSS設置溢出。我之所以說這是B/C的原因我不認爲有可能使用來自iframe的表單數據(儘管我可能是錯的)。例如:http://jsfiddle.net/ankpbwk9/ – 2014-11-05 06:40:15