Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Pass value from one div to other div php

    Code:
    <table>
        <tr>
        <td>
        S.No
        </td>
        <td>
        Column Name
        </td>
        <td>
        Action Buttons
        </td>
        </tr>
        <?php
        if($_POST['term'])
        {
        $data = mysql_query("SELECT * FROM institute where instiname like '%$term%'")
        or die(mysql_error());
        }
        else
        {
        $data = mysql_query("SELECT * FROM institute")
        or die(mysql_error());
        }
        $var =1;
        while($info = mysql_fetch_array( $data ))
        {
        ?>
        <tr>
        <td>
        <?php echo $var;?>
        </td>
        <td>
        <?php echo $info['instiname'] ;?>
        </td>
        <td>
        <img src="images/b_edit.png" title="Edit">
        </td>
        </tr>
        </table>
        <?php
        }
        ?>
    Here when i click on the edit image,a form should open with

    Code:
        <form>
        Column Name:
        <input type="text" name="ColumnName" value="<?php echo $info['instiname'] ; ?>" />
        </form>
    And this form should be in place of our table above....(Replace table with edit form once image(action button) is clicked)And also the id of that particular row should be passed.So that it can be updated to the db again.

    I tried to replace using show hide div. as follows:


    Code:
        <div id="columnDetails">
         <table>
            <tr>
            <td>
            S.No
            </td>
            <td>
            Column Name
            </td>
            <td>
            Action Buttons
            </td>
            </tr>
            <?php
            if($_POST['term'])
            {
            $data = mysql_query("SELECT * FROM institute where instiname like '%$term%'")
            or die(mysql_error());
            }
            else
            {
            $data = mysql_query("SELECT * FROM institute")
            or die(mysql_error());
            }
            $var =1;
            while($info = mysql_fetch_array( $data ))
            {
            ?>
            <tr>
            <td>
            <?php echo $var;?>
            </td>
            <td>
            <?php echo $info['instiname'] ;?>
            </td>
            <td>
           <!-- <img src="images/b_edit.png" title="Edit">-->
            <input type="image" src="images/b_edit.png"              onclick=if(document.getElementById('editContent').style.display=='none') 
                {                                            	 		document.getElementById('editContent').style.display='';
                                                    	 	document.getElementById('columnDetails').style.display='none';
                }
                else
                {
                document.getElementById('editContent').style.display='none';
                document.getElementById('columnDetails').style.display='';
                }
            </td>
            </tr>
            </table>
            <?php
            }
            ?>
        </div>
    The div to be replaced is
    Code:
         <div id="editContent" style="display: none;" >
        <form>
        Column Name:
        <input type="text" name="ColumnName" value="<?php echo $info['instiname'] ; ?>" />
        </form>
        </div>
    Now help me to pass the id of the column name selected/clicked to the edit form.

    Thanks & Regards,
    Passion Coder.
    Last edited by PassionCoder; 08-16-2012 at 06:24 AM. Reason: Change of [ICODE] to [/CODE]

  • #2
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    925
    Thanks
    76
    Thanked 29 Times in 29 Posts
    I think I may be able to help you on this but I can't read that very well dude.

    Where you have closed the CODE tags, just remove the I from infront of them. Instead of [/ICODE], do [/CODE].

    Regards,

    LC.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •