|
-
Jan 29th, 2008, 10:07 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] javascript onclick
I have two divs,
<input id="dragTest" name="dragTest" type="text" />
<div id="div1" class="div1" onclick="ObjectClick(this);">
</div>
<div id="div2" class="div2" onclick="ObjectClick(this);">
</div>
And a function:
<script type="text/javascript">
function ObjectClick(object)
{
//object.onmousedown = testFunction(object);
object.onmousedown = function()
{
var textBox = document.getElementById("dragTest");
textBox.value = object.id;
};
}
</script>
What it does is,it puts in a textbox the name of the div wihch has been clicked
The thing is, that it doesn´t work first time I click. Only the second I click on the div. That goes for both div1, and div2,.. then after that it works fine,..
Why could it be?
Thanks
-
Jan 29th, 2008, 10:13 AM
#2
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|