SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile onclick form submission

    Hi All.

    I have a html/php page which displays the results of a query of a mysql database in a table.

    I have used onmouseover and onmouseout to change the background colour of the <td> when the mouse travels over (obviously) without problem.

    I would like to use the onClick event handler to submit the form and $_POST a variable in a hidden field to another page when the <td> is clicked.

    I have scoured the web but don't seem to be able to get it together. If someone could point me to a suitable learning resource I would be most grateful.

    Regards and Thanks in anticipation.

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.S. I would prefer the contents of the <td> to look like regular contents and not be displayed as a <href> type link

    Cheers

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.P.S How sad am I sat here at 18:42 on a Saturday night doing this ?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    What are you having trouble with. The event part or the posting a form part.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, Thanks for the reply.

    I'm demonstrating my ignorance really.

    I don't know if there's an attribute of the onclick function that would simply redirect to the page in question where i could deal with the posted info or if i need to ascribe a call from the onclick event handler to a js function which then redirects to the page in question.

    Any help/advice would be most appreciated.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    You can use an anonymous function for the onclick handler if you don't want to use a function name.

    Code Javascript:
    document.getElementById('myElement').onclick = function () {
        document.URL = 'newpage.html';
    };
    Last edited by paul_wilkins; Feb 4, 2008 at 14:51.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for the reply you've pointed me in the right direction however I think I've bitten off more than I can chew and need to study javascript.

    Regards


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
  •