Results 1 to 7 of 7

Thread: Row Select, not quite working...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Row Select, not quite working...

    I am trying to submit a value, based on a button click, here is the php code for the button:

    echo "<input type='submit' width='100%' id='bonddescription' name='bonddescription[]' value='" .$row['description']. "'><input type='hidden' id='issueid' name='issueid[]' value='".$row['issue_id']."'>";

    This renders correctly, however when trying to obtain the submitted value it does not function as expected.

    var_dump($_POST[$bonddescription]); shows the value from the correct row

    var_dump($_POST[$issueid]); shows the full array, rather than the specific value from the selected row

    I need to display the bond description on the button and would prefer to keep the issue_id field hidden if possible, so how can I stop the entire array being submited and just post the single row value, as it does for the description?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Re: Row Select, not quite working...

    I can do this with checkboxes, but I can not find a single example of people doing this without checkboxes, which is odd as this scenario must come up all the time.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Row Select, not quite working...

    have you looked at the resulting HTML after the code has run, to make sure that it's correct? Because I don't think it's right...

    Here's what I suspect... you have a form tag... and then inside the form tag, you have a bunch of these rows. The reason that the correct bonddescription comes out is because it's a submit button... so THAT value gets submitted... along WITH EVERYTHING ELSE in the form... including ALL of your hidden fields.... and since they all have the same name... they get put into an array.

    So... having said that... the solution is to put EACH row into their OWN form tag... so that when it's submitted, ONLY those values are posted.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Re: Row Select, not quite working...

    So you mean like this:

    echo "<form>";
    echo "<input type='submit' width='100%' id='bonddescription' name='bonddescription[]' value='" .$row['description']. "'><input type='hidden' id='issueid' name='issueid[]' value='".$row['issue_id']."'>";
    echo "</form>";

    If I do that, click submit, then the print_r($_POST) simply reads: Array()

    So, something still isn't right :-(

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Row Select, not quite working...

    Not surprised... you didn't tell it to post the form... or where to post it to....
    Documentations
    You need to supply the Acton which is the URL to send the data to, and the Method, which is the manner in which the data is sent, it is either Get or Post. Get will send the data through the URL ala QueryString... while the post... well sends it through the headers as post data. By default when forms aren't specified, it 1) sends it via GET to the 2) same URL that sent it (in other words it sends it right back to the same page.)

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Re: Row Select, not quite working...

    Oooops!

    Yeah, sorry, should have spotted that.

    I've learnt something new today, I never realised you could have multiple forms on a single html page!

    That will help me out quite a lot, many thanks!

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Row Select, not quite working...

    Yeah... having multiple forms on a single html page isn't always obvious... most examples have one form, one page... I went through the same realization doing the same kind of thing back when....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width