Send Multiple Button Information Through Form
I have a form with multiple buttons and values. I want to submit which button was clicked when I press the submit button along with the value. I have the code below in a php loop w
Solution 1:
Use type="submit"
You could set your submit buttons like this:
<button type="submit" name="id1" value="value">Submit1</button>
<button type="submit" name="id2" value="value">Submit2</button>...
Then you can catch it with $_GET['id']
.
Solution 2:
Here is what I did. Added a hidden div and change that value using javascript functions changeValue1(val) and changeValue2(val).
<div id="Answertoggle18">
<div id="questions-box"><input type="hidden" name="question18" value="Question3"><input type="hidden" name="key" value="25"><input type="hidden" name="user" value="truthsandlie"><button type="button" name="yes25" onclick="changeValue1('no25')" id="answerf1" class="lietruth yes" >Yes</button><button type="button" name="no25" onclick="changeValue2('no25')" id="answer1" class="lietruth no" >No</button>
<input type="hidden" name="no25" id="no25" value="none">
<div id="questions">Question3</div>
</div>
</div>
<script type="text/javascript">
<!--
function changeValue1(val) {
var b = val;
document.getElementById(b).value = "yes";
}
function changeValue2(val) {
var b = val;
document.getElementById(b).value = "no";
}
//-->
</script>
Post a Comment for "Send Multiple Button Information Through Form"