shaoen01
12-17-2005, 09:14 AM
I wish to get the id of the <input type="image"> in the client-side before it generate the postback in the server-side. However, i always received a "null" or "[Object]", which is displayed using the "window.alert()" method.
This is my coding used to create the image button:
<input type="Image" name="1.jpg" id="1.jpg" onclick="Btn1_onClick(this)" src=Images/1.jpg class="removeBorder" onmouseover="this.className='applyBorder'"
onmouseout="this.className='removeBorder'" />"
Below is the Btn1_onClick() which is called onclick:
<script>
function Btn_onClick(control){
window.alert(window.document.getElementById(control.id));
//window.alert(window.event.srcElement);
}
</script>
I have also tried using the "window.document.getElementsByTagName(tag)", "window.document.getElementsByName(name)" and "window.event.srcElement", but still return the "[object]" message.
Btw, i am creating a user control (.ascx) in ASP.net, therefore i wont be able to use <form> tags, if this information is of any help. Thanks
This is my coding used to create the image button:
<input type="Image" name="1.jpg" id="1.jpg" onclick="Btn1_onClick(this)" src=Images/1.jpg class="removeBorder" onmouseover="this.className='applyBorder'"
onmouseout="this.className='removeBorder'" />"
Below is the Btn1_onClick() which is called onclick:
<script>
function Btn_onClick(control){
window.alert(window.document.getElementById(control.id));
//window.alert(window.event.srcElement);
}
</script>
I have also tried using the "window.document.getElementsByTagName(tag)", "window.document.getElementsByName(name)" and "window.event.srcElement", but still return the "[object]" message.
Btw, i am creating a user control (.ascx) in ASP.net, therefore i wont be able to use <form> tags, if this information is of any help. Thanks