I have a radio button and a submit button. On click of this submit button, I need to display a div.
My code is as follows:
<form action="" method="GET" name="myform">
<input type="radio" name="ID" value="total" id="radioInputValue"/>
<input type="submit" name="details1" value="Details"
onclick="return showDiv();"/>
<div id="element_to_pop_up" style="display: none;">
<?php
echo "DETAILS";
if (isset($_GET['details1'])) {
if (isset($_GET['ID'])) {
$n = $_GET['ID'];
echo "VALUE IS = $n";
}
} else {
echo "</br> DETAILS FAILED";
}?>
</div>
</form>
My JavaScript:
function showDiv() {
document.getElementById('element_to_pop_up').style.display = 'block';
return false;
}
Style:
#element_to_pop_up
{
background-color:#fff;
border-radius:15px;
color:#000;
padding:20px;
min-width:400px;
min-height: 180px;
}
I am getting the div on click of the details button. But its not entering the if condition .
Instead its giving the output as:
DETAILS
DETAILS FAILED
I want this as my output:
DETAILS
VALUE IS = total
How can i get this radio button value on clicking submit button, Plz help
just copy paste it: it works fine..
<form action="" method="POST" name="myform">
ONE<input type="radio" name="ID" value="total" id="radioInputValue" />
<input type="submit" name="details1" value="Details" onclick="return showDiv();" />
</form>
<div id="element_to_pop_up">
<?php
echo"DETAILS";
if(isset($_POST['details1']))
{
if(isset($_POST['ID']))
{$n=$_POST['ID'];
echo "VALUE IS = ".$n;
}
else
{
echo"</br> DETAILS FAILED";
}
}
?>
</div>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script>
function showDiv() {
document.getElementById('element_to_pop_up').style.display = 'block';
// return false;
}
</script>
Change your submit button like this:
<input type="submit" name="details1" value="Details" onclick="showDiv()" />
When you click your button, it displays the div.
Your PHP code should work, but make sure the file is .php and not .html or .htm.