SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how pass row id from db to a form inside a div

    I have a table full of data and each row is a link that shows a hidden div (made to look like a popup) that has a form to edit the "remarks" category.
    Normally I would pass the ID through to the next page that has the form in it to display the current remarks (from the database based upon the ID) in a text box for edit. Once the form is submitted it updates the database based upon the ID and redirects you back to the main page.
    My problem comes in when I'm only using
    Code:
    onClick="showDiv()"
    to show the div and don't know of a way to pass the id of the row that has been clicked on to this form. Does anyone know how to do that (or maybe I'm making no sense).

    Some code that I'm using:

    This pulls the data from the database to show my rows in my tables
    Code:
    $DispQuery = "SELECT * FROM $MaxxForceInventoryTable " . $FilterVariable . "ORDER BY COLOR, $orderby $ascdesc";
    $DispResult = mysql_query($DispQuery) or die(mysql_error().'<br />');
    while ($Row = mysql_fetch_assoc($DispResult))
    {
    Here's the code that gives me my mouse over clickable rows
    Code:
    ECHO "<TR BGCOLOR='" . $RowCOLOR . "' style='border-bottom-style: solid;' style='border-left-style: solid;' style='border-right-style: solid;' style=\"Cursor:Hand\" onClick=\"showDiv()\" onMouseOver=\"this.style.backgroundColor='#E4E7FF';\" onMouseOut=\"this.style.backgroundColor='" . $RowCOLOR . "';\">
    Here's showdiv()
    Code:
    function showDiv() {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById('hideshow').style.visibility = 'visible';
    }
    else {
    if (document.layers) { // Netscape 4
    document.hideshow.visibility = 'visible';
    }
    else { // IE 4
    document.all.hideshow.style.visibility = 'visible';
    }
    }
    }
    Let me know if more info is needed. I cannot show the actual page as it is on an intranet site... Thanks in advance!

  2. #2
    SitePoint Addict dbr's Avatar
    Join Date
    Aug 2006
    Location
    Tucked away in the mountains...
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you are mixing javascript with your php with your onClick="showDiv()"

    Can you use a query string with javascript? I don't know...

    My instincts would be to use a query string to pass the ID

    Maybe someone else knows...
    "Three components make an entrepreneur:
    the person, the idea, and the resources to make it happen."
    Anita Roddick ~British entrepreneur
    dbr founder of: ProximityCast.com

  3. #3
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to pass some extra variable in that showdiv function and generate dynamic divs
    i would suggest rather go with ajax here
    google for ajax solutions to display and hide exta info

    (if you cannot do that or find one ,then i will look into it...)

  4. #4
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Netscape 4 and IE4? Man you're taking Backward compatibility waaaay to serious.

    Seriously, just use some handy ajax functions, if you have the Possibility include jquers

    * Add an Event Listener on the Element (instead of onclick)
    * on click (event) get the id of the elment that has been clicked on using this
    * use the id to make an ajax call on a php script that then returns the html you want
    * append that html where you want

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you should be using a separate form for each row. You can identify the row using a hidden form input field.


Bookmarks

Posting Permissions

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