Skip to content Skip to sidebar Skip to footer

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).

<divid="Answertoggle18"><divid="questions-box"><inputtype="hidden"name="question18"value="Question3"><inputtype="hidden"name="key"value="25"><inputtype="hidden"name="user"value="truthsandlie"><buttontype="button"name="yes25"onclick="changeValue1('no25')"id="answerf1"class="lietruth yes" >Yes</button><buttontype="button"name="no25"onclick="changeValue2('no25')"id="answer1"class="lietruth no" >No</button><inputtype="hidden"name="no25"id="no25"value="none"><divid="questions">Question3</div></div></div><scripttype="text/javascript">
<!--
functionchangeValue1(val) {
var b = val;
    document.getElementById(b).value = "yes";
}

functionchangeValue2(val) {
var b = val;
    document.getElementById(b).value = "no";
}
//--></script>

Post a Comment for "Send Multiple Button Information Through Form"