Hi!
I have already found some answers to my question which help me a lot, but I need some further help if possible as I've not used any php before - not much javascript either!. I have a css / javascript menu, I would like the relevant area of the sub menu to stay visible when the page re-loads (when the user clicks on a link within the sub menu). You can see it working so far here
http://www.thefeelgoodguide.co.uk/test (am I allowed to put up links?)
I've found this answer by Ingwa... (pasted below) I have a php enabled server - but I just need to know what to do with this code - where to put it and if I need to edit it etc. Or do I have any other options?
Thank you in advance!!
Emma
Answer...
:Another simpler method could be to use a session variable on the server which stores a value. This remains "in state" while the users browser and connection to the server remain active. It's also non-dependent on javascript, which ensures that even if the users javascript is disabled, as long as the form can post to php then the code will work. The connection is only terminated after x number of seconds, which is usually set in the php.ini. To set a session do this:
<?php session_start();
$_SESSION['myvar'] = $_POST['dropdownfield']; // Selected test1
?>
<select name="'dropdownfield'" id="'dropdownfield'">
<option value="test1" <?php if($_SESSION['myvar'] == "test1"){ echo 'selected="selected";} ?>">test1</option>
<option value="test2" <?php if($_SESSION['myvar'] == "test2"){ echo 'selected="selected";} ?>>test2</option>
<option value="test3" <?php if($_SESSION['myvar'] == "test3"){ echo 'selected="selected";} ?>>test3</option>
<option value="test4" <?php if($_SESSION['myvar'] == "test4"){ echo 'selected="selected";} ?>>test4</option>
</select>
Hope this helps."
Start Free Trial