javascript - Automatically submit form with first option (PHP) -


i have project in must this: when user's page loads, gets personalized select box (with options generated php him) , then, when changes option, must change rest of content (on same page). example, let select box kind of user be:

  1. main content
  2. tools

now, idea have

<form action="processing.php"> <select name="choice" onchange="submit();"> etc. should pass user's choice processing.php. problem is, want first option automatically selected , content option appear when page loads - somehow first option automatically submitted. also, different kind of users should different options, , thought can use single page process these requests. achievable?

can please me idea on how submit form automatically first generated option? thank you.

you can use onchange event of selection. in handler can redirect

   let sel = document.getelementbyid('yourselect');    let form = document.getelementbyid('yourform');    sel.onchange = function() {       form.submit()    } 

Comments