Reputation: 543
Quick question,
Is it possible to have a form submitted when a radio button is selected (without javascript)? Kind of like a quiz?
Essentially, I no longer want a 'submit' button. The user will input several fields, then choose a radio button to submit the form. Each radio button will have a value associated, which I will need to capture.
Ideas?
Upvotes: 1
Views: 1709
Reputation: 3750
Short answer you cannot do it unless you use javascript.
Crazy answer yes you can. You can create radio-buton-like-looking images and use them as submit buttons to submit different forms. So you would be submitting the form when the user clicks submit button which looks like a radio button.
<FORM METHOD="POST" ACTION="">
<INPUT NAME="answer" value="answer is blue" TYPE="image" SRC="radio-button-image.jpg">
<INPUT NAME="answer" value="answer is red" TYPE="image" SRC="radio-button-image.jpg">
</FORM>
Upvotes: 5
Reputation: 639
Or with Ajax. You will need to provide a URL where you place a function actionAsynchronous
. In this function you will be able to get the selected radio button by using the POST variable. Then you will be able to manage the selected radio button value. This works for me using Php and Yii Framework.
Upvotes: 0
Reputation: 11415
Yes, with javascript
<script>
function submitOnClick(formName){
document.forms[formName].submit();
}
</script>
<form id="myForm" ...>
<input type="radio" onclick="submitOnClick('myForm')>
</form>
Upvotes: 0