top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Retaining listbox selections in PHP?

+1 vote
209 views

I have a listbox and when the user selects items they are highlighted. Then I process the form and when I generate the next web page (which has the listbox) I want the selected items still to be highlighted. Can I do this from PHP when I generate the listbox or must that be done client side from javascript?

posted Dec 20, 2013 by Garima Jain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

This is pretty basic HTML. Simply add the attribute selected="selected" to the option tag you want to be selected. You could do it in Javascript, but since you already have PHP generating the form you might as well do it there.

answer Dec 20, 2013 by Sheetal Chauhan
Similar Questions
+4 votes

Can anyone help me with these?

0 votes

recently I have made a form code and attached modules to it. but soon after I have reached an error saying Notice: Undefined index: module in F:\website\webpage\gate.php on line 68

here is the line that was mentioned

   switch ($_GET["module"]) {
    case "settings":
      Include('settings.php');
      break;
    default:
      break;
   }

I am also mentioning the code in the that I showed up ib the link

<a class="nav-link" href="gate.php?module=settings"> Settings </a>

please rectify this error for me and sorry for any in trouble

...