How to get table detail clicking on row?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dkate777
    New Member
    • Jun 2007
    • 18

    How to get table detail clicking on row?

    HI,

    I have table what I display on form. The table has multiple row with the same projectNumber, but difference description.
    I need to click on row and another form open with detail belong to this row.
    Is anybody can give code sample how to do this?
    How can i find out that i click on right row?

    Thanks
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    #2
    Hi,

    first thoughts are Javascript and clientside technologies, take a look at extjs.com the paged grid exampe. There are a number of the ajax components which will get you what you need.

    if you want a quick solution without heavy javascript / ajax you could always use a submit button formatted with CSS to look a little more like your page style. by setting the value of the submit on each row of the table to a key on your database and using array_flip on $_post you can work out which row has been selected..

    Hope this helps..

    Regards Purple

    Comment

    • dkate777
      New Member
      • Jun 2007
      • 18

      #3
      i think i like more second solution....... .....could you please base on my code give me exemple. I need to know how to add value to every row, i think i know how to do this, but i am not sure how to pass this to another page


      THIS IS MY TABLE DISPLAY FORM:
      [code=php]
      <?php
      echo "
      <tr>
      <td colspan='3'>
      <form name='controlte st' method='post'>
      <div style='overflow :auto; height:100px;'>
      <table align='center' width='90%' border-style='inset' padding='0' bgcolor='#FOFOF O' >
      <tr>
      <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Fu nctionality to be Tested</font></th>
      <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Pe rson Responsible</font></th>
      <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Du e Date</font></th>
      <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Co mpletion Date</font></th>
      </tr>";

      $controlQuery=" SELECT *
      FROM project_control test
      WHERE projectNumber=' $POST_projectNu mber'";
      $result=mysql_q uery($controlQu ery);
      $controlFound=f alse;
      $controlNumber= 0;
      $count=mysql_nu m_rows($result) ;
      while ($controlrow = mysql_fetch_arr ay($result)) {
      $controlFound=t rue;
      $controlNumber= $controlNumber+ 1;

      echo "
      <tr bgcolor='white' > " ;

      echo "<tr input type='hidden' name='control' value='$control Number'> ";
      echo "<tr input type='hidden' name='projectNu mber[$controlNumber]'
      id='projectNumb er' value='$control row[projectNumber]'> ";


      echo "<td bgcolor='white' class='tdnavy' width='300px'>\ n";
      echo "<a onClick='update Project(\"testc ontrol\")' href='javascrip t:void(0)'>";
      echo "$controlro w[shortdescriptio n]</a> ";
      echo " </td>
      <td bgcolor='white' class='tdnavy' >"; echo get_user_info($ controlrow[personresponsib le],'name'); echo "</td>
      <td bgcolor='white' class='tdnavy'> ";echo convert_date($c ontrolrow[duedate],'fromSQL');
      echo "</td>
      <td bgcolor='white' class='tdnavy'> ";
      if (convert_date($ controlrow[completiondate],'fromSQL')<>'0 0/00/0000'){
      echo convert_date($c ontrolrow[completiondate],'fromSQL');
      }
      else echo '' ;
      echo "</td>";
      echo "</tr>";

      }

      echo "</table></div></form>";
      echo "<input type='hidden' name='maxcontro lNumber' value='$control Number'> ";
      echo "</tr>";

      ?> [/code]

      [Please use CODE tags when posting source code. Thanks! --pbmods]

      THIS IS THE FORM I WANT TO DISPLAY WHEN I CLICK ON ANY ROW.

      [code=html]
      <div id='testcontrol Table' style='position :absolute;
      top:150px;
      left:50px;
      width:1000px;
      height:550px;
      z-index:4;
      visibility="hid den"'>
      <form name='testcontr olForm' method='post' onSubmit='retur n validateField(" testcontrol")'>
      <input type='hidden' name='userNumbe r' value='<?php echo $POST_userNumbe r; ?>'>
      <input type='hidden' name='projectNu mber' value='<?php echo $POST_projectNu mber; ?>'>
      <input type='hidden' name='shortdesc ription' value='<?php echo $POST_shortdesc ription; ?>'>
      <input type='hidden' name='controlSt atus' value='restore' >
      <table class='projectB ar' align='right' width='100%' height='50%'>
      <tr>
      <th colspan='4' align='center' >
      <h3>Update Test Requirement</h3>
      </th>
      </tr>
      <?php

      $controlQuery=" SELECT *
      FROM project_control test
      WHERE projectNumber=' $POST_projectNu mber'";
      $result=mysql_q uery($controlQu ery);
      $controlFound=f alse;
      // $controlNumber= 0;
      while ($controlrow = mysql_fetch_arr ay($result)) {
      $controlFound=t rue;
      // $controlNumber= $controlNumber+ 1;
      $shortdesc=$con trolrow[shortdescriptio n];
      }
      }
      ?>
      <tr>
      <th> Short Description:
      </th>
      <td>
      <input readonly type='text'
      size='50'
      name='shortdesc ription'
      value='<?php echo $shortdesc ?>'
      maxlength='50'> </input>
      </td>

      </tr>
      <tr>
      <th>Functionali ty to be Tested:</th>
      <td>
      <textarea wrap='soft' rows='5' cols='52' name='funcText' value=''></textarea>
      </td>
      <th> Testing Result:</th>
      <td>
      <textarea wrap='soft' rows='5' cols='52' name='testresul t' value=''></textarea>
      </td>
      </tr>
      <tr>
      <td align='right'>
      Due Date:
      </td>
      <td >
      <input name='DueDate'
      type='text'
      size='15'
      onBlur='chkDate Fld(this,"DueDa te",true,true )'
      value=''>
      <a href="javascrip t:showCal('Cale ndar15')">
      <img border='0' src='/images/b_calendar.png'
      alt='Get Date'>
      </a>
      </td>
      <td> Completion Date:</td>
      <td>
      <input name='Completio nDate'
      type='text'
      size='15'
      onBlur='chkDate Fld(this,"Compl etionDate",true ,true)'
      value=''>
      <a href="javascrip t:showCal('Cale ndar16')">
      <img border='0' src='/images/b_calendar.png'
      alt='Get Date'>
      </a></td>
      </tr>
      <tr>
      <td align='right' >
      Person Responsible:
      </td><td>
      <input readonly type='text'
      size='25'
      name='personres ponsible'
      maxlength='25'
      value=''></input>
      </td>
      <td> Completed By:
      </td>
      <td>
      <input type='text'
      size='25'
      name='completed by'
      value=''
      maxlength='25'> </input>
      </td>
      </tr>
      </tr>

      <tr>

      <th colspan='4' align='center'>
      <input type='submit' value='Submit' class='fancyBut ton' >
      <input type='button' value='Cancel' class='fancyBut ton' onClick='closeC ontrol("close") '>
      </th>
      </tr>
      </table>
      </form>
      </div>[/code]

      Comment

      • Purple
        Recognized Expert Contributor
        • May 2007
        • 404

        #4
        Hi,

        I am having difficulty with readability of your code in the post - if you use code tags the code will be formatted with line numbers - makes it much easier to talk about..

        Anyhow the logic for the select in the table

        select records to be displayed including a key field
        Loop the fetch2
        [PHP]echo "<tr><td><i nput type = 'submit' name = '".$keyfield ."' value = 'select'></input></td>more detail for the record in detail tags</tr>";[/PHP]
        end loop

        when the form is processed the $_POST array will have an element with a name of the record key and a value of select.

        if you copy and array_flip($_PO ST) you then have the record key = $new_array['select']

        Hows that ?

        Purple

        Comment

        • dkate777
          New Member
          • Jun 2007
          • 18

          #5
          i am not really understand how exactly to do this, but i can try and let you know
          I am still not clear, but i can play with this

          Comment

          • Purple
            Recognized Expert Contributor
            • May 2007
            • 404

            #6
            Hi dkate777

            Apologies if my answer was not clear.

            Which bit are you having a problem understanding ?

            Ask for clarification and we can assist further.

            Regards Purple

            Comment

            Working...