Page 1 of 1
how to make a select box invisible using PHP?
Posted: Mon Nov 03, 2008 1:54 am
by swetha
<select name="ntype" id="itype" style="visibility:hidden">
The above is the select statement for making the visibility hidden through html.
How do i write the above statement in PHP ?i want the following select box to be visible only when the particular following radio button is visible.the following statement which i have written doesnt work.
Code: Select all
<select name="ntype" id="itype" if((!$_POST['lineformat']=="sort")) echo "style=\"visibility:hidden\"";?>
<option value="asc">Ascending</option>
<input type="radio" name="lineformat" value="sort" >Sort Lines<br/>
pls help.how do i do this?
Re: how to make a select box invisible using PHP?
Posted: Mon Nov 03, 2008 3:14 am
by pavanpuligandla
<select name="ntype" id="itype" style="visibility:hidden">
The above is the select statement for making the visibility hidden through html.
How do i write the above statement in PHP ?i want the following select box to be visible only when the particular following radio button is visible.the following statement which i have written doesnt work.
Line number On/Off | Expand/Contract
1.
2. <select name="ntype" id="itype" if((!$_POST['lineformat']=="sort")) echo "style=\"visibility:hidden\"";?>
3. <option value="asc">Ascending</option>
4.
<input type="radio" name="lineformat" value="sort" >Sort Lines<br/>
pls help.how do i do this?
hii..
herez one solution using php which you've to do this with form action..
alternatively u can use ajax or javascript.
Code: Select all
<?PHP
if (isset($_POST['Submit'])) {
$selected_radio = $_POST['lineformat'];
if ($selected_radio = = 'sort') {
hide your select box ntype in the form manually.
}
else {
// write what u want to see.
}
}
?>
Code: Select all
<FORM name ="form" method ="post" action ="test.php">
<Input type = 'Radio' Name ='lineformat' value= 'sort'
<Input type = 'Radio' Name ='lineformat' value= 'others'
<P>
<Input type = "Submit" Name = "Submit" >
</FORM>
hope this helps u...
Re: how to make a select box invisible using PHP?
Posted: Mon Nov 03, 2008 3:27 am
by aceconcepts
Using your original code:
Code: Select all
<select name="ntype" id="itype" if((!$_POST['lineformat']=="sort")) echo "style=\"visibility:hidden\"";?><option value="asc">Ascending</option>
You could write it like this:
Code: Select all
<select name="ntype" id="itype" <? if($_POST['lineformat']!="sort") echo 'style="visibility:hidden;"'; ?>><option value="asc">Ascending</option></select>