SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fire Chosen jquery's onchange for js click image selects item

    I am using [Image Click Selects Dropdown Item][1]. When using Chosen jQuery, onchange not fire. I am not familiar with js, thus would like to know code exactly on "$("form_field").addEvent('change', ... );".

    HTML Code:
    <select id="DropdownListID" name="DropdownListName" onchange="SelectAnItem(this.selectedIndex)">
        <option>Select here or click a pattern above.</option>
        <option>Fleur</option>
        <option>Nine Patch</option>
        <option>Pink Gate</option>
        <option>Sand Dollar</option>
        <option>Sandria</option>
        <option>Blue Wheel</option>
        </select>



    Code javascript:
        // Place 2 --
        // Specify the leading characters of the id values assigned 
        //    to the images. The leading characters would be the id 
        //    value up to the image number.
     
        var LeadingImagesIdValue = "ImageID";
     
        //
        // End of customization.
        // // // // // // // // // //
     
        function SelectAnItem(ndx) {
        var d = document.getElementById(DropdownListIdValue);
        for( var i=0; i<d.length; i++ ) {
        d[i].selected = false;
        var imgi = i + 1;
        if( imgi < d.length ) {
            document.getElementById(LeadingImagesIdValue+imgi).style.borderColor = "#ffffff"; }
        }
        d[ndx].selected = true;
        if( ndx > 0 ) { 
        document.getElementById(LeadingImagesIdValue+ndx).style.borderColor = "#999999"; }
        }
     
        SelectAnItem( document.getElementById(DropdownListIdValue).selectedIndex );
        //--></script>


    [1]: https://www.willmaster.com/library/m...pdown-item.php

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by alouty View Post
    I am using [Image Click Selects Dropdown Item][1]. When using Chosen jQuery, onchange not fire. I am not familiar with js, thus would like to know code exactly on "$("form_field").addEvent('change', ... );".
    Please stop using //<!-- and //--> for those only serve a beneficial purpose when want to stop web browsers that are unable to understand script tags from showing the code on the web page. The list of web browsers that this affects is pretty much only Netscape 1.0 from 1995, because Netscape 2.0 in 1996 invented JavaScript - so please - there's no need for those comment tags now.

    On your query - may I please see the rest of the script that you are wanting to convert? What you have provided there is somewhat incomplete, so a link to a website with further details about it would be useful.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •