I am trying to get the value of an input-button, because I am trying to set up a "system" where the user can decide between different options and based on what he have chosen an e-mail get sent with the information. Since I am new to php I am trying to keep it simple.
This is how the input buttons looks like:
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE1" />
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE2" />
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE3" />
They have the same name but different values, I need to get the VALUE attribute and storage it in a php variable. Since I want to send the information per e-mail.
Wrap the buttons inside a form and change the type into type=submit
<form action="handle.php" method="POST">
<input name="form-thema" class="fwd_btn ipt_btn" type="submit" value="VALUE1" />
<input name="form-thema" class="fwd_btn ipt_btn" type="submit" value="VALUE2" />
<input name="form-thema" class="fwd_btn ipt_btn" type="submit" value="VALUE3" />
</form>
handle.php
<?php
echo $_POST['form-thema'];
?>
I would add an onclick event on each button like so:
HTML
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE1" onclick="choose_value('VALUE1')" />
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE2" onclick="choose_value('VALUE2')" />
<input name="form-thema" class="fwd_btn ipt_btn" type="button" value="VALUE3" onclick="choose_value('VALUE3')" />
Javascript
function choose_value(val) {
alert(val);
// You probably need to send this to a php file via ajax
}