#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    5
    Rep Power
    0

    PHP/Javascript: POST from link


    I have a HTML table, generated in PHP and populated with data from a MySQL DB. Each column header, a regular HTML link, needs to have the ability to sort the data by that column. However, my department only allows a specific item to be passed as GET; everything else must be POSTed. I can get it to work by using the query string. However, is there a way to make the link POST?

    I had another item on top of that. I'm sure I can do it through a custom JavaScript function. However I dont have access to the <header> portion of the page, as my department uses submenus that take care of headers and footers. Is there any way to put multiple statements in the href portion of the link? i.e. a href="javascriptne(); two(); three();">? If so, whats the punctuation?
    Last edited by drgnflame13; June 2nd, 2003 at 08:02 AM.
  2. #2
  3. Gogo Google.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Location
    Adelaide, Australia
    Posts
    226
    Rep Power
    13
    I don't think it's possible to send POST vars via a link, not unless you use a form and then call it's submit() method.

    As for your other question, yes you can. Syntax is as follows:

    Code:
    <a href="javascript:one(); two(); three()">Link</a>
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2002
    Location
    close to the edge
    Posts
    1,035
    Rep Power
    69
    Make the link at the top of each column submit a form that has a hidden form element holding the appropriate information.

    I hope that helps,
    cranium
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    5
    Rep Power
    0
    Alright now. I've got a form that contains three hidden elements: questionID, sortID, and orderID. Now, I want the user to be able to click on one of the header links at the top, and it sets the hidden fields and submits. For example, if they click on the "Date Submitted" link, the values should change to

    questionID = 0;
    sortID = "department";
    orderID = "DESC";

    I know this doesnt make much sense, but let's just say thats what the link did. I tried putting them all into one statement in a href, but it didnt work.

    <a href="javascript: document.sortQForm.questionID.value = 0; document.sortQForm.sortID.value = "department"; document.sortQForm.orderID.value = "DESC"; document.sortQForm.submit();">blah</a>

    That keeps giving me errors on submitting. Is the syntax right? Or do I have to do something else?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    5
    Rep Power
    0
    Nevermind, it seems to work now that I rewrote it. Must have forgotten something. Anyways, thanks for the help. If i Have any other questions, I know where to come

IMN logo majestic logo threadwatch logo seochat tools logo