SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery Button Post it's ID

    i have the following code which sets the button's ID
    PHP Code:
    <a href="#confirmation"><button data-inline="true" id="'.$device['name'].'-on">'.$device['name'].' On</button></a
    what i would like is the button when pressed to post the ID value to index.php?id=

    This probably a 2 min job for some one on here but i am struggling!

    Code:
    $("button").click(function() {
      alert(this.id);
    });
    the above does alert the id i am after but no idea how to post the id.

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    For a form input field, you can only POST the name and the value. If you want to POST any extra data, you'll need to use a hidden input field.

    PHP Code:
    <input type="hidden" name="somename" value="<?php echo 'somevalue' ?>">
    If you're trying to determine which button was pressed, to check for a button press, use:

    HTML Code:
    <button name="myButtonName">Click Me!</button>
    PHP Code:
    if(isset($_POST['myButtonName'])){
         
    //do something

    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would an ajax post request work?
    i was originally using get but had issues so just want to post the id nothing else.


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
  •