Guys,
First post on Byte, so hello all!
I was wondering if I could pick somones brain regarding what I hoped would be an easy message display function, unfortunately it is causing me a lot of frustration.
I am looking to display an alert box with a custom message depending on what textfield a user clicks on.
For example, if I had a simple form with the following:
I was hoping the function would be as simple as something like this (but I have little experience using getElementById) and not sure you can even do this?
Can anyone shed any light on a suitable solution to my problem? Thanks for your help in this.
First post on Byte, so hello all!
I was wondering if I could pick somones brain regarding what I hoped would be an easy message display function, unfortunately it is causing me a lot of frustration.
I am looking to display an alert box with a custom message depending on what textfield a user clicks on.
For example, if I had a simple form with the following:
Code:
<form name="form1"> <input type="text" name="textbox1" onclick(displaymessage)> <input type="text" name="textbox2" onclick(displaymessage)> </form>
Code:
<script language="javascript"> function DisplayMessage() { var textbox_name = document.getElementById.name; if(textbox_name=="textbox1") { alert(textbox_name); } } </script>
Comment