i want to hide and show a section in html

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lokesh_kumar_s
Forum Commoner
Posts: 48
Joined: Mon Apr 13, 2009 5:39 am
Contact:

i want to hide and show a section in html

Post by lokesh_kumar_s »

eg:

Code: [Select]
<div id='con'>
<h1>hello</h1>
</div>
<div id='cal'>
<h2>hello</h2>
</div>


i want to hide div id 'con' and show div id 'cal' on some event . and toggle on another event. so please tell me how can i hide it
Marinusjvv
Forum Commoner
Posts: 29
Joined: Wed Dec 02, 2009 5:59 am

Re: i want to hide and show a section in html

Post by Marinusjvv »

Why don't you use an if statement and document.write?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: i want to hide and show a section in html

Post by papa »

Or using CSS:

Google
lokesh_kumar_s
Forum Commoner
Posts: 48
Joined: Mon Apr 13, 2009 5:39 am
Contact:

Re: i want to hide and show a section in html

Post by lokesh_kumar_s »

Marinusjvv wrote:Why don't you use an if statement and document.write?

Code: Select all

 
<javascript type="text/javascript">
function Enable(form)
{
    //myform.rdoWise.value
    //a variable that will hold the index number of the selected radio button
    alert("coming here");
    var theone;
    for (i=0;i<form.rdoDomainType.length;i++)
    {
        if (form.rdoDomainType[i].checked==true)
        {
            theone=i;
            break //exist for loop, as target acquired.
        }
    }
    //alert(myform.rdoWise[theone].value);
    var val=form.rdoDomainType[theone].value;
    alert(val);
    if(val=="con")
    {
        document.getElementById('ForCallCenter').style.display='hidden';
        //document.getElementById('ForCallCenter').
        document.getElementById('ForContractor').style.display='visible';
    }
    else if(val=="cal")
    {
        document.getElementById('ForCallCenter').style.display='visible';
        document.getElementById('ForContractor').style.display='hidden';
    }
}
</javascript>
 
<div id="ForCallCenter">
<?php if(!isset($_SESSION['secman'])): ?>
<tr>
<th class="RowWiseHeader" align="right" style="width: 301px">Company Name&nbsp;&nbsp;&nbsp;&nbsp;
</th>
<td align="left">
<?php include('inc/DbConnect.php');
    $result=mysql_query("select CompanyName from SecManager_Profile where CompanyName !=''") or die("could not execute");
                            ?>
<select name="txtCompanyName" style="width: 158px">
<option value="">SELECT</option>
<?php while($array=mysql_fetch_row($result)): ?>
<option value="<?php echo $array[0]; ?>"><?php echo $array[0]; ?></option>
<?php endwhile; ?>
<?php mysql_close(); ?>
</select></td>
</tr>
<?php endif; ?>
<!--/div-->
</div>
<div id="ForContractor">
hffh
</div>
 
i want to do like this can i use any other tags other than div for that
Post Reply