<script>
                        function get_input(id)
                        {   
                            var value_id = id.split('_',2);
                            var index = value_id[1];
                            var input_id = 'input_'+value_id[1];
                            var value =  document.getElementById(id);
                            var input = document.getElementById(input_id);
                            var num = <?php echo $_SESSION['max_num']; ?>;
                            var i= 0;
                            while( i< num)

                            {
                                if(i==index)
                                {    // alert(index);
                                     //alert(i);
                                     // alert(input_id);
                                    $("#"+input_id).css({"display":"block" , "width":"106px" , "height":"20px"});

                                    value.style.display='none';
                                    //input_id.style.width=106;
                                    //input_id.style.height=20;

                                }
                                else
                                {
                                    value.style.display='none';
                                    //$("#"+input).css({"display":"none"});
                                }
                            i++;
                            }

                        }

                        function get_value(id,cat_id)
                        {

                            var input_id = id.split('_',2);
                            var item_id = 'item_'+input_id[1];
                            var input =  document.getElementById(id);
                            var field_value = document.getElementById(item_id);
                            var cat_name = input.value; 

                            //alert(num);
                            //alert(item_id);
                            //alert(cat_name);

                            if(cat_name =='') { 
                              $("#input_id").addClass("error");
                              $("#input_id").focus();
                              return false; } else { $("#input_id").removeClass("error"); }


                            input.style.display='none';
                            field_value.style.display='block';

                            $("#"+item_id).load("ajax_pages.php?id="+cat_id+"&cat_name="+cat_name+"&act=update_catt");

                        }</script>



<?php
$query="SELECT * FROM category ";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
$_SESSION['max_num']=$num;
while ($i < $num) 
 {
    $id = mysql_result($result,$i,"cat_id");
    $category = mysql_result($result,$i,"cat_name"); 
?>                                                  
    <th width="20"><span><?php echo $id;?></span></th>


<th width="230"><span class="show cat_text" id="item_<?php echo $i;?>" onClick="get_input(this.id)"><?php echo $category;?></span><input id="input_<?php echo $i;?>" class="hide" name="new_id" type="text" value="<?php echo $category;?>" style="float:left;" onBlur="get_value(this.id,<?php echo $id;?>);"></th>

                                                          <th width="40">
                                                              <div class="actions_menu">
                                                                <ul>
                                                                    <li><a class="edit" href="">Edit</a>
                                                                    </li>
                                                                    <li><a class="action4" href="" 
                                                                        onclick="return del();">Delete</a></li>
                                                                </ul>
                                                             </div>
                                                        </th>
                                                        </tr>
<?php $i++; 


}?>
this is my code.... i want to update categories on click... via ajax... it is done.. but there is a issue i want to remove is that onClick just one input field will open the rest will b displayed none(even if u click the other one)..... i 've tried many things please help me if some one can......

Not going to look at your code. Will answer from the header... To do that, you just need to check whether or not the new element (text field) has been added to the page. If it already exists, don't add a new one. A simple way to check is to add a unique ID to the element when you create one. When you check, call for the element.

//For example (not JQuery)
if (!document.getElementById('id_name')) {  // element doesn't exist
  ...  // create the new element and also don't forget to give an id of 'id_name'
}

hmmm ... not sure if I missunderstand the question here ...
if we're talking about showing existing components, then it might very well be the point that he wants to change the css theme (visible setting) on the onClick.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.