javascript - how do I check a radio button after being redirected -


how can check radio button after being redirected new web page ?

i've tried script :

<script>     function affstatus(choix) {         document.getelementbyid(choix).checked = true;         document.location.href = "pagelink?tri="+ choix;     } </script> 

with these radio buttons

sort : <input type="radio" name="choice" id="ddc" value="ddc"                 on="affstatus('ddc')" checked />activity             <input type="radio" name="choice" id="di" value="di"                 onclick="affstatus('di')" />date  <input                 type="radio" name="choice" id="nm" value="nm"                 onclick="affstatus('nm')" />nbm <input                 type="radio" name="choice" id="p" value="p" onclick="affstatus('p')" />pseudo             (a-z) 

ps: i'm redirecting user same displayed page.

edit: i'm programming java ee using eclipse not php.

but doesn't work me. think i've wrote wrong script can't solution fix it. please ?

actually there no need have separate code check radio buttons same names. automatically uncheck other , check new one.

i found mistake have on="affstatus('ddc')" instead of onclick="affstatus('ddc')"

i wonder why not using jquery,

edited:

since want select radio after refresh , dont use backend code url param 'tri', function you..

function affstatus(choix) {     document.getelementbyid(choix).checked = true;     document.location.href = "pagelink?tri="+ choix; }  window.onload=function(){     var selected_radio = geturlparameter('tri');     console.log(selected_radio)     document.getelementbyid(selected_radio).checked = true; }  function geturlparameter(name) {     return decodeuricomponent((new regexp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null } 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -