how to make a select box invisible using PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
swetha
Forum Commoner
Posts: 88
Joined: Wed Sep 10, 2008 11:00 pm

how to make a select box invisible using PHP?

Post 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?
User avatar
pavanpuligandla
Forum Contributor
Posts: 130
Joined: Thu Feb 07, 2008 8:25 am
Location: Hyderabad, India

Re: how to make a select box invisible using PHP?

Post 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...
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: how to make a select box invisible using PHP?

Post 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>
Post Reply