Results 1 to 2 of 2

Thread: [RESOLVED] javascript onclick

  1. #1
    Hyperactive Member
    Join Date
    Mar 06
    Location
    Madrid
    Posts
    325

    Resolved [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&#180;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

  2. #2
    Hyperactive Member
    Join Date
    Mar 06
    Location
    Madrid
    Posts
    325

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •