FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » html php form second drop down select dependant list to keep selected value
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: html php form second drop down select dependant list to keep selected value [message #186187 is a reply to message #186186] Thu, 19 June 2014 20:45 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 6/19/2014 1:22 PM, ba pa wrote:
> I was just looking at this... using session_start and $_SESSION array...
>
> Would it goes as:
> document.getElementById("MyDropDown").value = '<?php echo $_SESSION['MyStoredValue']; ?>'
>
> or
>
> jQuery('#MyDropDown').val('<?php echo $_SESSION['MyStoredValue']; ?>');
>
> thanks,
> Pascal
>

Pascal,

Pretty much. Just a couple of things to remember:

session_start() must be called before ANY output to the client. This
includes <!DOCTYPE...>, <HEAD...> and even blank space.

This must be done on EVERY page which uses $_SESSION values.

And, of course, you must store the value in the $_SESSION, also.

And you should check to see if the value is set before using it (i.e.
the first time through it may not be set); if not, you should supply a
default value.

As for whether your jQuery code will work or not - try a javascript
newsgroup. But the PHP code looks OK.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Authentication Framework?
Next Topic: for who use mailchimp: google considers the emails received as advertising?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 11 23:49:12 GMT 2024

Total time taken to generate the page: 0.04008 seconds