Discussion:
Generating an option list with a default
Jennifer
2014-01-25 20:45:04 UTC
Permalink
Hello all,

We have a PHP form with a static <option> list, where people can request a product sample.

http://www.superiorshelving.com/mfg/aigner/sample.php

There are links on multiple pages that call this page. I would like to send a different default option to that form from each of those pages so that the customer doesn't have to pop-up the list to choose it manually. Of course, if they go to that form directly, there shouldn't be a default.

What would be the best way to handle this? I'm thinking to have code generate the list with the default undefined, and then have the links to that page pass a variable to the form to set a default. Does that sound like it would work?

Any other ideas are appreciated!

Thank you,
Jenni

Superior Shelving Systems::::....
http://www.SuperiorShelving.com

The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984

Wire LAN Shelving:
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
John Meyer
2014-01-25 20:48:48 UTC
Permalink
That's one way. Another is to base the default option on the referer page.
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to send a different default option to that form from each of those pages so that the customer doesn't have to pop-up the list to choose it manually. Of course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code generate the list with the default undefined, and then have the links to that page pass a variable to the form to set a default. Does that sound like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 16:28:48 UTC
Permalink
Post by John Meyer
That's one way. Another is to base the default option on the referer page.
The referrer is unreliable. You cannot ensure it is always available.
Post by John Meyer
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stephen
2014-01-25 20:56:45 UTC
Permalink
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to send a different default option to that form from each of those pages so that the customer doesn't have to pop-up the list to choose it manually. Of course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code generate the list with the default undefined, and then have the links to that page pass a variable to the form to set a default. Does that sound like it would work?
Any other ideas are appreciated!
You could code the links as a form with the link like a submit button
and the default hard coded on each page.

Then on the product sample page check to see if the default is set, and
if so, use it.
--
Stephen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 16:32:19 UTC
Permalink
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
You could code the links as a form with the link like a submit button and the
default hard coded on each page.
Why a form? Just use an anchor tag. No need for a form/button. Well, I
guess if you want to use a <button ..></button> element, you won't need a form.
Then on the product sample page check to see if the default is set, and if so,
use it.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jennifer
2014-02-07 15:38:46 UTC
Permalink
I received an email from this list saying that some emails to me are bouncing, so if anyone replied to this topic, I never received it. I'm not ignoring you. :(

Jenni

Superior Shelving Systems::::....
http://www.SuperiorShelving.com

The (Storage|Office|Display|Warehouse) Shelving Specialists
Since 1984

Label Holders:
http://www.superiorshelving.com/mfg/aigner/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Matijn Woudt
2014-02-10 23:13:12 UTC
Permalink
Post by Jennifer
I received an email from this list saying that some emails to me
are bouncing, so if anyone replied to this topic, I never received it. I'm
not ignoring you. :(
Jenni
You can always check the archives to see if you missed any of the replies:
http://marc.info/?l=php-general&m=139068274024513&w=3

Regards,

Matijn
Jim Giner
2014-02-11 13:59:10 UTC
Permalink
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to send a different default option to that form from each of those pages so that the customer doesn't have to pop-up the list to choose it manually. Of course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code generate the list with the default undefined, and then have the links to that page pass a variable to the form to set a default. Does that sound like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's
the way to do it. So simple, flexible and easily implemented. Set a
session var that your central piece of code checks as it builds the
select list and you're all set.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 16:26:47 UTC
Permalink
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that he
didn't want to have a default for the form value, then he would have empty
that session variable. So, not only are you setting a variable on each page
you want it done on, you need to make sure that variable is erased/emptied on
every page load that should not have a default. That to me is a headache
waiting to happen.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-02-11 16:55:20 UTC
Permalink
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default. That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option
in mind as the default to be selected when going to the central 'list'
page. It is not meant to be the user's option, but the intermediate
page's. If the user did however go directly to the list page, then
there is no default.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 17:54:58 UTC
Permalink
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default. That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate page's. If the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would update that
session variable. Now, I go to a page that doesn't have/need a default but
from there I click the link that takes me to the page with the form. Now, if
I didn't clear the session variable on that last page that didn't have a
default, then it would use the value set on the previous page instead of not
having a default.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-02-11 18:00:29 UTC
Permalink
Post by Jim Lucas
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default. That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate page's. If the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 18:18:37 UTC
Permalink
Post by Jim Giner
Post by Jim Lucas
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default. That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate page's. If the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
What? I think you need to think your suggestion through a little more.

So, as I laid out above, on one page (set a default), move to another page
(set a default). Now I go to a page that should not have a default (but I
still have the previous page default set). At this point, the session
variable needs to be cleared otherwise if I go to the form page, it will use
the session variable from my previous page. I can't clear it here either,
otherwise I will not have anything to use when I create the list.

Clearing that session variable on all the pages that should not have a default
is what I said would be the PITA to maintain.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-02-11 21:06:05 UTC
Permalink
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default.
That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate page's. If the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
What? I think you need to think your suggestion through a little more.
So, as I laid out above, on one page (set a default), move to another
page (set a default). Now I go to a page that should not have a default
(but I still have the previous page default set). At this point, the
session variable needs to be cleared otherwise if I go to the form page,
it will use the session variable from my previous page. I can't clear
it here either, otherwise I will not have anything to use when I create
the list.
Clearing that session variable on all the pages that should not have a
default is what I said would be the PITA to maintain.
We apparently aren't seeing the task the same way.

1 - several pages all call the same "list-maker" page.
2 - those several pages each has a different desired default setting.
3 - each of those #2 pages sets the session var to the value it wants
4 - the list-maker page checks for the existence of the session var and
copies to a local var (or sets local var to '') and unsets the session var.
5 - list maker page does its thing with the value of the local var set in #4

A call directly to the 'list-maker' page defaults to nothing as local
var will direct. As I read the original statement, there was no reason
to expect the user to be reading several pages before going to the
"list-maker" page. If that is the case, then the last page obviously
controls the activity. If there is a page that doesn't want the list to
have a default selection, it should then set the session var
accordingly, as all the other pages would be doing.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 21:46:47 UTC
Permalink
Post by Jim Giner
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default.
That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate page's. If the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
What? I think you need to think your suggestion through a little more.
So, as I laid out above, on one page (set a default), move to another
page (set a default). Now I go to a page that should not have a default
(but I still have the previous page default set). At this point, the
session variable needs to be cleared otherwise if I go to the form page,
it will use the session variable from my previous page. I can't clear
it here either, otherwise I will not have anything to use when I create
the list.
Clearing that session variable on all the pages that should not have a
default is what I said would be the PITA to maintain.
We apparently aren't seeing the task the same way.
1 - several pages all call the same "list-maker" page.
2 - those several pages each has a different desired default setting.
3 - each of those #2 pages sets the session var to the value it wants
4 - the list-maker page checks for the existence of the session var and copies
to a local var (or sets local var to '') and unsets the session var.
5 - list maker page does its thing with the value of the local var set in #4
A call directly to the 'list-maker' page defaults to nothing as local var will
direct. As I read the original statement, there was no reason to expect the
user to be reading several pages before going to the "list-maker" page. If
that is the case, then the last page obviously controls the activity. If
there is a page that doesn't want the list to have a default selection, it
should then set the session var accordingly, as all the other pages would be
doing.
The OP did say "Of course, if they go to that form directly, there shouldn't
be a default." So, to me, that says their is a possibility for a user to
browse to pages that DO want a default option to be set, but then to also be
able to view pages that do not require a default to be set. So, if the
possibility exists that a user could land on a pages that doesn't require a
default after visiting a page that does, the page that doesn't require the
default would need to clear that previously set default.

To me, that would be a PITA to have to make sure that each page you build
would need to either set to unset that session var. Seems like one additional
step that doesn't need to exist.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-02-11 22:02:06 UTC
Permalink
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Lucas
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where
people can
request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I
would
like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it
manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to
have
code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course that's the
way to do it. So simple, flexible and easily implemented. Set a session var
that your central piece of code checks as it builds the select list
and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default.
That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate
page's. If
the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
What? I think you need to think your suggestion through a little more.
So, as I laid out above, on one page (set a default), move to another
page (set a default). Now I go to a page that should not have a default
(but I still have the previous page default set). At this point, the
session variable needs to be cleared otherwise if I go to the form page,
it will use the session variable from my previous page. I can't clear
it here either, otherwise I will not have anything to use when I create
the list.
Clearing that session variable on all the pages that should not have a
default is what I said would be the PITA to maintain.
We apparently aren't seeing the task the same way.
1 - several pages all call the same "list-maker" page.
2 - those several pages each has a different desired default setting.
3 - each of those #2 pages sets the session var to the value it wants
4 - the list-maker page checks for the existence of the session var and copies
to a local var (or sets local var to '') and unsets the session var.
5 - list maker page does its thing with the value of the local var set in #4
A call directly to the 'list-maker' page defaults to nothing as local var will
direct. As I read the original statement, there was no reason to expect the
user to be reading several pages before going to the "list-maker" page. If
that is the case, then the last page obviously controls the activity. If
there is a page that doesn't want the list to have a default
selection, it
should then set the session var accordingly, as all the other pages would be
doing.
The OP did say "Of course, if they go to that form directly, there
shouldn't be a default." So, to me, that says their is a possibility
for a user to browse to pages that DO want a default option to be set,
but then to also be able to view pages that do not require a default to
be set. So, if the possibility exists that a user could land on a pages
that doesn't require a default after visiting a page that does, the page
that doesn't require the default would need to clear that previously set
default.
To me, that would be a PITA to have to make sure that each page you
build would need to either set to unset that session var. Seems like
one additional step that doesn't need to exist.
But again - I'm assuming that the user goes directly from a page to the
list-maker page and not from page1 to page2 and then to the list-maker
page with the premise that the user wants the 'page1' selection. Again
- if the user is browsing thru whatever set of pages that then requires
the list to be built, the last one should be the determiner of what gets
selected when that list is built. It's a one-to-one relationship and I
see nothing in the OPs layout that would make me think of anything more
complicated than this.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 22:13:32 UTC
Permalink
Post by Jim Giner
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Giner
Post by Jim Lucas
Post by Jim Lucas
Post by Jim Giner
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where
people can
request
a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I
would
like to
send a different default option to that form from each of those pages so
that the customer doesn't have to pop-up the list to choose it
manually. Of
course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to
have
code
generate the list with the default undefined, and then have the links to
that page pass a variable to the form to set a default. Does that sound
like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I had your thought in mind halfway thru your question. Of course
that's the
way to do it. So simple, flexible and easily implemented. Set a
session var
that your central piece of code checks as it builds the select list
and you're
all set.
I see one issue with doing it this way. If a person visited a page that
he didn't want to have a default for the form value, then he would have
empty that session variable. So, not only are you setting a variable on
each page you want it done on, you need to make sure that variable is
erased/emptied on every page load that should not have a default.
That
to me is a headache waiting to happen.
The OP's original idea was that any specific page have a specific option in
mind as the default to be selected when going to the central 'list' page. It
is not meant to be the user's option, but the intermediate
page's. If
the
user did however go directly to the list page, then there is no default.
Ok, I understand that. But, lets say that I browse one page that has a
default, then another that has a default, each time doing so would
update that session variable. Now, I go to a page that doesn't
have/need a default but from there I click the link that takes me to
the page with the form. Now, if I didn't clear the session variable on
that last page that didn't have a default, then it would use the value
set on the previous page instead of not having a default.
So - simply have the list-generator page unset the var.
What? I think you need to think your suggestion through a little more.
So, as I laid out above, on one page (set a default), move to another
page (set a default). Now I go to a page that should not have a default
(but I still have the previous page default set). At this point, the
session variable needs to be cleared otherwise if I go to the form page,
it will use the session variable from my previous page. I can't clear
it here either, otherwise I will not have anything to use when I create
the list.
Clearing that session variable on all the pages that should not have a
default is what I said would be the PITA to maintain.
We apparently aren't seeing the task the same way.
1 - several pages all call the same "list-maker" page.
2 - those several pages each has a different desired default setting.
3 - each of those #2 pages sets the session var to the value it wants
4 - the list-maker page checks for the existence of the session var and copies
to a local var (or sets local var to '') and unsets the session var.
5 - list maker page does its thing with the value of the local var set in #4
A call directly to the 'list-maker' page defaults to nothing as local var will
direct. As I read the original statement, there was no reason to expect the
user to be reading several pages before going to the "list-maker" page. If
that is the case, then the last page obviously controls the activity. If
there is a page that doesn't want the list to have a default
selection, it
should then set the session var accordingly, as all the other pages would be
doing.
The OP did say "Of course, if they go to that form directly, there
shouldn't be a default." So, to me, that says their is a possibility
for a user to browse to pages that DO want a default option to be set,
but then to also be able to view pages that do not require a default to
be set. So, if the possibility exists that a user could land on a pages
that doesn't require a default after visiting a page that does, the page
that doesn't require the default would need to clear that previously set
default.
To me, that would be a PITA to have to make sure that each page you
build would need to either set to unset that session var. Seems like
one additional step that doesn't need to exist.
But again - I'm assuming that the user goes directly from a page to the
list-maker page and not from page1 to page2 and then to the list-maker page
with the premise that the user wants the 'page1' selection. Again - if the
user is browsing thru whatever set of pages that then requires the list to be
built, the last one should be the determiner of what gets selected when that
list is built. It's a one-to-one relationship and I see nothing in the OPs
layout that would make me think of anything more complicated than this.
Well, lets agree to disagree. I tend to think along the lines that the users
of my apps will end up doing things I would find completely counter intuitive
and ill logical, and designing against that.
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph Becker
2014-02-11 21:57:15 UTC
Permalink
Post by Jim Giner
Post by Jennifer
We have a PHP form with a static <option> list, where people can
request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would
like to send a different default option to that form from each of
those pages so that the customer doesn't have to pop-up the list to
choose it manually. Of course, if they go to that form directly,
there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have
code generate the list with the default undefined, and then have the
links to that page pass a variable to the form to set a default. Does
that sound like it would work?
Any other ideas are appreciated!
I had your thought in mind halfway thru your question. Of course that's
the way to do it. So simple, flexible and easily implemented. Set a
session var that your central piece of code checks as it builds the
select list and you're all set.
Um, a session variable might not work for all visitors, unless they have
cookies enabled or the server is configured to pass the session ID in
the query string (what could not be viable for security reasons wrt.
sensitive information stored in the same session, and might not be
generally the best idea wrt. search engines).

Why not simply add the appropriate value as get parameter to the links?
--
Christoph M. Becker
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-02-11 22:03:21 UTC
Permalink
Post by Christoph Becker
Post by Jim Giner
Post by Jennifer
We have a PHP form with a static <option> list, where people can
request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would
like to send a different default option to that form from each of
those pages so that the customer doesn't have to pop-up the list to
choose it manually. Of course, if they go to that form directly,
there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have
code generate the list with the default undefined, and then have the
links to that page pass a variable to the form to set a default. Does
that sound like it would work?
Any other ideas are appreciated!
I had your thought in mind halfway thru your question. Of course that's
the way to do it. So simple, flexible and easily implemented. Set a
session var that your central piece of code checks as it builds the
select list and you're all set.
Um, a session variable might not work for all visitors, unless they have
cookies enabled or the server is configured to pass the session ID in
the query string (what could not be viable for security reasons wrt.
sensitive information stored in the same session, and might not be
generally the best idea wrt. search engines).
Why not simply add the appropriate value as get parameter to the links?
And that works too!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-02-11 16:47:23 UTC
Permalink
Post by Jennifer
Hello all,
We have a PHP form with a static <option> list, where people can request a product sample.
http://www.superiorshelving.com/mfg/aigner/sample.php
There are links on multiple pages that call this page. I would like to send a different default option to that form from each of those pages so that the customer doesn't have to pop-up the list to choose it manually. Of course, if they go to that form directly, there shouldn't be a default.
What would be the best way to handle this? I'm thinking to have code generate the list with the default undefined, and then have the links to that page pass a variable to the form to set a default. Does that sound like it would work?
Any other ideas are appreciated!
Thank you,
Jenni
Superior Shelving Systems::::....
http://www.SuperiorShelving.com
The (Storage|Office|Home|Warehouse) Shelving Specialists
Since 1984
http://www.superiorshelving.com/mfg/nexel/pages/wire-shelving-chrome.php
I would suggest having either an anchor or a button on the first page linking
to the second page with the form.

So, on the first page, you would have something like this:

Universal way
<a href="sample.php?d=4">Go to Sample page</a>
or
<form action="sample.php" method="get">
<input type="hidden" name="d" value="4" />
<input type="submit" value="Got to Sample page" />
</form>

or an HTML5 method
<button formmethod="get" formaction="sample.php?d=4">Go to Sample page</button>


Then, once you get to generating the form -> select box options, do something
like this. I assume you are looping through some sort of list to generate the
options. In my example, I am using an ID instead of a label. But you could
use a label instead of an ID, you would simply match it to the value of the
option instead of the ID of the option.

<?php

... Get your options together into an array ...

$id = intval($_GET['d']);

foreach ( $options AS $k => $option ) {
$k = htmlspecialchars($k);
$option = htmlspecialchars($option);

$sel = ( $id == $k ? ' selected="selected"' : '' );

echo "\t<option value=\"{$k}\"{$sel}>{$option}</option>\n";
}
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Loading...