I am trying to integrate a custom page into a shopping cart app written in PHP. The custom page is basically a part finder widget that helps customers find a car part based on the car's make, model, year, etc. This custom page has a form that submits the page to itself. It does this because I have four drop down menus, and the data in each following drop down is dependent on the previous selection. Since there was so much data, I didn't want to preload the page using Javascript. Instead, I did everything in PHP and just had the form submit to itself every time a drop down selection is made like this:
[HTML]<select name="carmake" onchange="this. form.submit()">[/HTML]
When I run this widget independently, it works. However, when I try to integrate it into the shopping cart, I run into problems because custom pages must be accessed through a "target" variable in the query string of the URL like this: http://www.mysite.com/index.php?target=custompage
When I submit the form, instead of going to this page: http://www.mysite.com/index.php?targ...age&make=honda
It goes to this page: http://www.mysite.com/index.php?make=honda
In other words, the page is reloading to the index page, instead of to my custom page. So my question is this: Is it possible to reload to a URL that has a query string appended to it, and then add new variables to the query string when the page submits to itself?
The interesting thing is that when I type the whole URL directly into the address bar, the page works. I just can't accomplish this same behavior through the select lists.
I've been looking all over, and I haven't found anything helpful. Any help would be greatly appreciated.
6 3725
I am trying to integrate a custom page into a shopping cart app written in PHP. The custom page is basically a part finder widget that helps customers find a car part based on the car's make, model, year, etc. This custom page has a form that submits the page to itself. It does this because I have four drop down menus, and the data in each following drop down is dependent on the previous selection. Since there was so much data, I didn't want to preload the page using Javascript. Instead, I did everything in PHP and just had the form submit to itself every time a drop down selection is made like this:
[HTML]<select name="carmake" onchange="this. form.submit()">[/HTML]
The "action" attribute of the form is set to submit to the current page.
When I run this widget independently, it works. However, when I try to integrate it into the shopping cart, I run into problems because custom pages must be accessed through a "target" variable in the query string of the URL like this: http://www.mysite.com/index.php?target=custompage
When I submit the form, instead of going to this page: http://www.mysite.com/index.php?targ...age&make=honda
It goes to this page: http://www.mysite.com/index.php?make=honda
In other words, the page is reloading to the index page, instead of to my custom page. So my question is this: Is it possible to reload to a URL that has a query string appended to it, and then add new variables to the query string when the page submits to itself? If it's possible, can somebody show me how to do this? I'm thinking that maybe my action attribute needs to be set to something different.
The interesting thing is that when I type the whole URL directly into the address bar, the page works. I just can't accomplish this same behavior through the select lists.
I've been looking all over, and I haven't found anything helpful. Any help would be greatly appreciated.
Atli 5,058
Recognized Expert Expert
Hi.
You could add a hidden <input> element in your form, which contains the variable you need to pass.
Like so: -
$targetValue = $_GET['target'];
-
echo "<input type=\"hidden\" name=\"target\" value=\"$targetValue\" />";
-
Now, given that the form uses the GET method, the 'target' variable will be added to the url, along with it's old value and any other <input> elements that belong to the form.
Hi.
You could add a hidden <input> element in your form, which contains the variable you need to pass.
Like so: -
$targetValue = $_GET['target'];
-
echo "<input type=\"hidden\" name=\"target\" value=\"$targetValue\" />";
-
Now, given that the form uses the GET method, the 'target' variable will be added to the url, along with it's old value and any other <input> elements that belong to the form.
Thanks for the response! I actually just found this out myself a little while ago. I changed the form method to POST, too. Thanks again.
Atli 5,058
Recognized Expert Expert
Thanks for the response! I actually just found this out myself a little while ago. I changed the form method to POST, too. Thanks again.
I'm glad you found your answer.
Changing to POST is a very good idea!
Good luck and I hope I'll be seeing you around.
pbmods 5,821
Recognized Expert Expert
Heya, Mike.
I'll go ahead and move your thread to the Forum where an Expert will be more likely to find it.
pbmods 5,821
Recognized Expert Expert
Merged duplicate threads.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rbt |
last post by:
Say I have a list that has 3 letters in it:
I want to print all the possible 4 digit combinations of those 3
letters:
4^3 = 64
aaaa
|
by: Martin |
last post by:
There is an Access table on the network. 15 users who do not have Access are
connected to the network. Is there a way for each user to be able to enter one
or more rows containing 3 or 4 columns to Excel on his machine and then press a
button or something and append that data to the Access table on the network? Any
suggestions on what the code...
|
by: Danny |
last post by:
I want to extract a subset of fields from one table into another
the master table has many fields
the subset has about half, but still many.
Is there a way I can just append the master into the subsets structure and
this way only the existing fields in the destination will be filled?
That would be great, but it seems that the append query...
|
by: karinski |
last post by:
Hi All,
I have a split f/e - b/e setup on my database with RWOP queries on the
front end. The code below gets a PO number(s), and vendor name from a
multi choice list box on another form. It then assigns these values,
plus a new receiving number, to the current form. The SQL string is an
append query that copies select fields from the PO...
|
by: WordVBAProgrammer |
last post by:
I've been struggling with this for a few days now. It worked
originally as plain VB-type strings, but for some reason ceased
creating the FileNm. I changed the code to use StringBuilder, but
only get the file name, not the path.
Can someone point out my error? See notes below code.
....
Dim strFileNm As String
Dim FileNm As New...
| |
by: solar |
last post by:
I have copied a function that appends from table orders2 into table
orders1 the row that has the value SubOrder = True in the table
orders2. This function finds the highest ordered in the table orders2.
But I want to find the highest ordered in the table orders2 instead.
In short, I want to append the order from the table orders2 into the...
|
by: robertmeyer1 |
last post by:
Hey,
I have 2 append queries. The first is based off of code given and works great. For the second, I followed the format of the 1st and adjusted it to meet my needs. Query 1 works great. It appends each specific clientId to the table when the command button from form 1 is selected (code below). The 2nd query works as well. But it will...
|
by: Tobiah |
last post by:
I wanted to do:
query = "query text" % tuple(rec.append(extra))
but the append() method returns none, so I did this:
fields = rec
fields.append(extra)
query = "query text" % tuple(fields)
|
by: dougmeece |
last post by:
Morning Everyone...
I have a table that needs to be append to and also updated. All the fields in the table are populated with data from the text boxes and combo boxes on a form. The Date Submitted defaults to 1/1/00 if the cboSubmittedBox field is "No". Otherwise it is selected from a calendar. The Date Entered field defaults to the current...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |