473,388 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Pre-selected Option of a Select, coming from different page?

Hello,
I have a question I hoping someone here could help me. I have a web and in some pages I want to put a contact link, wich will get the user to a diferent page. So in depending on witch page the user comes from I want to preselect an option on a select.

For example I am in this page mobile-web-design.php and there is a link named Contact Us, witch takes me to the contact.php. In the contact.php, there is a select with several Subjects, for example, Mobile Web Design, Graphic Design etc... so I want to preselect the "Mobile Web Design" Subject.

Thank you!
Oct 17 '10 #1
2 1783
dlite922
1,584 Expert 1GB
Use a session variable. And assign it a value when a visitor visits each of those pages except for the contact page.

On the contact page the session variable will contain the name of the last page they visited.

On each page:
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['subject'] = 'Name of This Page'; 
  2.  
On the contact page:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <select>
  3.    <option value="page1" <?php if $_SESSION['subject'] == 'page 1' echo "selected='selected'"; ?>>Page One</option>
  4.    <option value....
  5. .
  6. .
  7. .
  8. </select>
  9.  
  10.  
Make sense?


Dan
Oct 18 '10 #2
I am agree with dlite922 this is the most easier way to do this. We can also do this by getting the file name
if($file=="mobile-web-design.php") {
$subject = mobile web design;
}
and place the subject in the contact link
<a href="contact.php?subject=<?php echo $subject;?>"Contact</a>

Its up to you which way you adopt, but I still prefer dlite922 approach
Oct 19 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
3
Pre
by: Neal | last post by:
A few questions about pre... When presenting preformatted text using the white-space: pre; property/value, Opera renders long lines at small viewport widths as exiting the borders of the...
7
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
7
by: Roderik | last post by:
Hi, When I use <pre> inside my <td> cells, the text won't flow to a new line and the table gets to large in width. This will appear in Firefox this way, Internet Explorer will wrap the lines,...
17
by: TheKeith | last post by:
Isn't there a style for preformatted text, instead of having to use the pre tags? Help would be appreciated--thanks.
3
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
12
by: Vadim Guchenko | last post by:
Hello. I'm using the following code: <html> <head> <style type="text/css"> pre {display: inline;} </style> </head>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.