FUDforum - خوراک RDF
http://fudforum.org/forum/index.php
html php form second drop down select dependant list to keep selected value
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186184&th=123541#msg_186184
Is there a way to have the second drop down select list to keep the selected value after user hits submit?
Thansk,
Pascal]]>pppbbb102014-06-19T16:20:39-00:00Re: html php form second drop down select dependant list to keep selected value
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186185&th=123541#msg_186185
> Hi,
>
> Is there a way to have the second drop down select list to keep the selected value after user hits submit?
>
> <select class="select_Y" name="FLexA" id="LexikA">
> <option value="0" >Please choose a context...</option>
> <option value="1" <?php if (@$_POST['FLexA']==1) {echo "selected='selected'"; } ?> >Human nature , Health, Ethic, Religion...</option>
> </select>
>
> <select class="select_Y" name="FLexB" id="LexikB" jqsd:depends_on="LexikA" jqsd:hide_mode="disable">
> <option value="0" rel="0" >Please choose...</option>
> <option value="2" rel="1" <?php if (@$_POST['FLexB']==2) {echo "selected='selected'"; } ?> >Business, Law, Financezzz...</option>
> <option value="3" rel="1" <?php if (@$_POST['FLexB']==3) {echo "selected='selected'"; } ?> >Sport, competition...</option>
> </select>
>
> Thansk,
> Pascal
>
The best way to save values across pages is in the $_SESSION superglobal.
--
==================
Remove the "x" from my email address
Jerry Stuckle jstucklex@attglobal.net
==================]]>Jerry Stuckle2014-06-19T17:08:01-00:00Re: html php form second drop down select dependant list to keep selected value
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186186&th=123541#msg_186186
Would it goes as:
document.getElementById("MyDropDown").value = '<?php echo $_SESSION['MyStoredValue']; ?>'
thanks,
Pascal]]>pppbbb102014-06-19T17:22:57-00:00Re: html php form second drop down select dependant list to keep selected value
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186187&th=123541#msg_186187
> 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@attglobal.net
==================]]>Jerry Stuckle2014-06-19T20:45:57-00:00Re: html php form second drop down select dependant list to keep selected value
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186188&th=123541#msg_186188
pppbbb102014-06-19T21:40:32-00:00