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)

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




                        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; 


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




$query="SELECT * FROM category ";
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">
                                                                    <li><a class="edit" href="">Edit</a>
                                                                    <li><a class="action4" href="" 
                                                                        onclick="return del();">Delete</a></li>
<?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......

Recommended Answers

All 2 Replies

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.