I'm trying to Hide/Show a DIV based upon a Variable. This is what I have so far.
I POST the variable into an INPUT
<input type="text" id="showhidediv" name="showhidediv" value="<?php echo $ta; ?>">
This is my jQuery
<script type="text/javascript">
$(document).ready(function(){
var show=('#showhidediv');
if(show == 2) {
$('#landlord').show();
}
else if(show == 1)
{
$('#landlord').hide();
}
});
</script>
When the variable is posted into the form from another form the DIV doesn't hide.
Where have I gone wrong?
Why do you need javascript for this, just hide the element with CSS based on the PHP variable ?
<input type="text" id="showhidediv" name="showhidediv" value="<?php echo $ta;?>">
<div id="landlord" style="display:<?php echo $ta==2 ? 'block':'none' ?>"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With