ivane Posted July 6, 2011 Share Posted July 6, 2011 I am new to here. I would like to design a PHP page for simple education system. The page consist of 2 <tables>: 1. one comprehension passage; 2. 5 questions of multiple choices (e.g. option A to option D). For the table 1, it's just display static passage. But, in table 2, I would like to design two columns, one for question and the multiple choices, another column for "check the solution" ( this part will further discuss below). Column 1 for table 2, I can display question and multiple choices (radio button format) in one row. Column 2 for table 2, I need to display "check for solution" in hyperlink format. This part may need some Javascript to help. I need to allow user click the hyperlink, next will pop up a message box or small windows box to display the user's selected value from radio button (multiple choices) and also display the actual answer retrieved from database and stored in array at PHP page. Link to comment https://forums.phpfreaks.com/topic/241192-hyperlink-post-value-from-radio-button-and-display-on-javascript-message-box/ Share on other sites More sharing options...
TeNDoLLA Posted July 6, 2011 Share Posted July 6, 2011 So you got some sort of idea what you want to do. So what you got now? And what is the problem what you need help with? Link to comment https://forums.phpfreaks.com/topic/241192-hyperlink-post-value-from-radio-button-and-display-on-javascript-message-box/#findComment-1238920 Share on other sites More sharing options...
dcro2 Posted July 6, 2011 Share Posted July 6, 2011 Here's a simple example of what you could do using jQuery: <script src="jquery.js"></script> <script> function checkAnswer(id) { selected = $("input[name=answer_"+id+"]:checked").val(); $.get("checkanswer.php", {id: id}, function(data) { alert("Your answer: "+selected+"\n\nCorrect Answer: "+data); }); } </script> <input type="radio" name="answer_123" value="A" checked="checked">A</input> <input type="radio" name="answer_123" value="B">B</input> <input type="radio" name="answer_123" value="C">C</input> <input type="radio" name="answer_123" value="D">D</input> <a href="#" onclick="checkAnswer(123); return false;">Check Answer</a> Just code getanswer.php to take $_GET['id'] and get its answer from the database, assuming each question has some kind of unique id. Link to comment https://forums.phpfreaks.com/topic/241192-hyperlink-post-value-from-radio-button-and-display-on-javascript-message-box/#findComment-1239024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.