Hello
I am relatively new to javascript.
I am trying to dynamically load a form when the user clicks the edit button for his/her name. The onclick event points to a JS function that changes the innerHTML of the foll div.
But I get a js Object expected error.
Please help me understand, why I get this error.
Any suggestions on a good debbuger for javascript, will also be very helpful.
Thanks
reena
Here is the code:
form code :
[HTML]<b>FIRST NAME:</b>Reena<img src="/fast/images/tdd/btn_md_edit.jpg " onclick="javasc ript:changeFirs tName()"/> <br/></tr>
<tr><div id="first"></div></tr>[/HTML]
js functions :
I am relatively new to javascript.
I am trying to dynamically load a form when the user clicks the edit button for his/her name. The onclick event points to a JS function that changes the innerHTML of the foll div.
But I get a js Object expected error.
Please help me understand, why I get this error.
Any suggestions on a good debbuger for javascript, will also be very helpful.
Thanks
reena
Here is the code:
form code :
[HTML]<b>FIRST NAME:</b>Reena<img src="/fast/images/tdd/btn_md_edit.jpg " onclick="javasc ript:changeFirs tName()"/> <br/></tr>
<tr><div id="first"></div></tr>[/HTML]
js functions :
Code:
<script language="JavaScript">
function changeFirstName()
{
var first= document.getElementById("first");
first.innerHTML="<form name="fname" method="post" action="employee_account_page.dl"><input type=\"text\" name=\"firstname\"><img src=\"/fast/images/tdd/btn_md_save.jpg\" onclick=\"javascript:saveFirstName()\"/></form>";
}
function saveFirstName()
{
var firstform=document.getElementById("fname");
if(isEmpty(firstform.firstname.value))
alert("Please provide your first name!");
else
firstform.submit();
}
function isEmpty (val) {
if ( val.replace(/^\s*|\s*$/g,"") == "" ) {
return true;
} else {
return false;
}
</script>
Comment