why I cant access to value of hidden input element by javascript? -


i have page cant use value of hidden input in if clause. , dont print in page. use javascript command past days , worke dont work here. code is:

<script type="text/javascript">  function ch() {     alert(); document.write(" brnd = "); var c=document.getelementbyid("brnd").value;  document.write(document.getelementbyid("brnd").value); document.write(document.forms["br"]["brnd"].value); } window.onload=ch(); </script> </head>  <body > <form id="br">     <input type="hidden" id="brnd" value="0000pp"  /> </form> <p>page description. </p> <div id="brands" style=""   >                             <ul style="height:20% !important;width:90% !important;">                                 <li><a href="yat.php" style="color:#000">y.t</a></li>                                 <li><a href="ez.php" style="color:#000">ez</a></li>                                 <li><a href="ami.php" style="color:#000">am</a></li>                                 <li><a href="gr.php" style="color:#000"> group iks</a></li>                                 <li><a href="fr.php" style="color:#000">frtc</a></li>                                 <li><a href="ar.php" style="color:#000">armco</a></li>                             </ul>                         </div>  </body> 

where problem in opinion?

=============================================

@rocket hazmat: note.one problem place of ch.i move ch after input , work.but have problem dont know how solved. anyway code work now.thanks all.

window.onload=ch(); 

this line run ch() function , set window.onload return value. ch() returns undefined, not setting onload anything.

you want do:

window.onload = ch; 

in javascript, functions other variables. can pass them around normally. use () call them.

note: document.write should never used. using other issue here. once page loaded, document.write destroy page. erase all , replace whatever passed.

because of this, hidden element deleted , therefore can no longer value.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -