Get and Set value in javascript -


i have function show popup. when user clicks link popup gets opened. problem have set value in popup input type not able in javascript. doing :

var email_id = document.getelementbyid("username_login").value; 

from here getting value:

<tr>     <td bgcolor="#ffffff" style="padding-left:10px;">         <input type="text" name="username" id="username_login">     </td> </tr> 

popup html

<form  method="post" name="forgotpsswd"> <table cellspacing="0" cellpadding="7" width="100%" border="0">     <tbody>             <tr>             <td width="26%" align="right">email address:</td>             <td width="1%" style="padding:7px 5px;">:</td>             <td width="74%"><input type="text" value="" size="33" class="border_grey" id="emailid" name="email"></td>         </tr>               </tbody> </table> 

 document.getelementbyid("emailid").value= email_id; //this not setting value 

i have added fiddle in code works fine.

http://jsfiddle.net/swaprks/uvjo86xa/

<form  method="post" name="forgotpsswd"> <table cellspacing="0" cellpadding="7" width="100%" border="0">     <tbody>             <tr>             <td width="26%" align="right">email address:</td>             <td width="1%" style="padding:7px 5px;">:</td>             <td width="74%"><input type="text" value="" size="33" class="border_grey" id="emailid" name="email"></td>         </tr>               </tbody> </table>     </form>  document.getelementbyid("emailid").value= "test@gmail.com"; //this not setting value 

try setting value after html has rendered. i.e @ end , before tag. in case, "email_id", try hard coding , check issue is.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

python - RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK -