0

I'm trying to load session values for textboxes,radio buttons,dropdown and checkboxes (for back button click scenario).

when I navigate from one page to next page I do store all checked/selected/entered values in session.

when i click on back button I want to load all those values from session in form

Problem:

specially having problem to load data on dropdown which is created dynamically while loading page( want to load selected value)

Any help would be appreciable!

I tried using selected index property but didn't work.

can I achieve it without changes the actual form?

can I have something by which I can load session values from function by setting few attributes or so! Thanks!

Update:

 function LoadList()
    {

            var addselect="";
            for(var i=11; i<=4999;i++)
            {
              if(addselect=="")
              {
                addselect="<option> "+i+"</option>";

              }
             else
              {
                addselect+= "<option> "+i+"</option>";
              }
            }



            //console.log(addselect);
         $('#9').html(addselect);
         var textToFind =<?php echo $_SESSION['sys'];?>

            var dd = document.getElementById('9');
            for (var i = 0; i < dd.options.length; i++) 
            {
                if (dd.options[i].text === textToFind) 
                {
                    dd.selectedIndex = i;
                    break;
                }
            }
    }
Emma
  • 617
  • 2
  • 12
  • 29

1 Answers1

0

For a dropdown, you need to put

selected="selected"

in the option that is to be selected.

Pawel J. Wal
  • 1,166
  • 1
  • 11
  • 24
Terry
  • 332
  • 1
  • 15