Results 1 to 3 of 3

Thread: Why do tab links ignore onclick event

  1. #1
    Join Date
    May 2008
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Why do tab links ignore onclick event

    1) Script Title: Tab Content Script (v 2.2)

    2) Script URL (on DD): http://dynamicdrive.com/dynamicindex17/tabcontent.htm

    3) Describe problem:

    I need tab links to fill specific form input field with a predefined value when clicked on.
    But I can't get it work. As if tab content script is taking exclusive rights on onclick event.
    Is there a way?


    Code:
    <form name="myform">
      <input type="text" name="targettextfield" />
    </form>
    
    <ul id="tabs" class="shadetabs">
    
      <!-- Does not address targeted text field -->
      <li><a href="#" class="selected" rel="prev1" onclick="document.myform.targettextfield.value='new value';">tab 1</a></li>
    
      <li><a href="#" rel="prev2">tab 2</a></li>
    
    </ul>
    
      <!-- This works as expected -->
    <a href="#" onclick="document.myform.targettextfield.value='new value';">js test 1</a>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It does take control over, basically writes, the onclick event itself. If there is one already, it overwrites it. You could change your event to one of the following, whichever works out best for you, but if onclick was your first choice, onmousedown is probably the next best thing:

    onmousedown
    onmouseup
    onmouseover
    onmouseout
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    adibih (05-13-2008)

  4. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Or, you can change the Tab Content script to use the onmousedown event instead of onclick to select the tabs, leaving the later open. Inside the .js file, change the highlighted part to the new value in red:

    Code:
    				this.tabs[i].onmousedown=function(){
    					tabinstance.expandtab(this)
    					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
    					return false
    				}

Bookmarks

Posting Permissions

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