Jump to content

Php Post Get Problems!


Christopherx

Recommended Posts

Hey there guys.

 

Right my problem is pretty straight forward, but it's a bit of a catch-22!

 

I have a table, that displays products in it. At the end I have a query string link to add to the basket, that passes the product ID of the item to pass. This morning I decided to implement a feature to allow users to select more than one of the same item via a quantity text box, and then hit the query string.

 

Now I realise that I can't update the query string inside the HTML form, so I've been trying to work out how to get the value in the text box by deducing it from the user ID. My attempt was:

 

Set the method of the form to "get"

Append the username onto the end of it's corresponding quantity textbox.

The query string still passes the value of the product ID to the .php file.

 

When I hit the php file, I grab the product ID, and GET the value in the text box. Then I go about my business.

Alas, it doesn't fire the form, the Textbox isn't loaded into the GET array until a submit button is clicked. The problem is

if I hit a submit button, then I lose the product ID being passed to the .php file and can no longer identify the relevant textbox.

 

This IS for a University coursework project; I've posed on a few forums and I know that's important :P

 

Any help would be much appreciated! Thankyou very much guys :)

Edited by Christopherx
Link to comment
Share on other sites

The simplest and most straight-forward method, if you want individual 'add to basket' links/buttons, one per product, and a quantity text box per product, would be to make a form for each product and change the existing link into a submit button for the form. The submitted text box would be the quantity and you would pass the id value as a hidden field in the form.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.