javascript - Document.myform alternative js -


i have got working js, problem is. have include php file generated programmer. file huge , can't rewrite everything.

in js use this: document.myform1.cid.options[i].selected = true;

but problem id of form createquestion-form. , has no name.

how replace myform1 createquestion-form?

this full script:

function search()             {                 var searchkeyword=document.getelementbyid("searchtext").value;                 var sellength=document.myform1.cid.length;                 for(var i=0; i<sellength;i++)                 {                     var searched_text = document.myform1.cid.options[i].text;                     var ismatch = searched_text.search(searchkeyword);                     if(ismatch != -1)                     {                         document.myform1.cid.options[i].selected = true;                         document.myform1.cid.options[i].style.color = 'red';                     }                     else                     {                         document.myform1.cid.options[i].style.color = 'black';                     }                 }             } 

just use document.getelementbyid

form = document.getelementbyid('createquestion-form'); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -