#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    20
    Rep Power
    0

    calling stylesheets using a combo box in javascript


    Hi I'm trying to create a combobox that when user selects any items on list, it will call a style sheet:

    Hers a portion of what my code looks like

    <SCRIPT>
    function loadXML() //load all the documents
    {
    xml=new ActiveXObject("microsoft.XMLDOM");
    xml.load('macStore_xml.xml');//loads xml file
    xsl0=new ActiveXObject("microsoft.XMLDOM");
    xsl0.load('all_products_xsl.xsl');//loads first stylesheet
    xsl1=new ActiveXObject("microsoft.XMLDOM");
    xsl1.load('desktops_xsl.xsl');//loads second stylesheet
    xsl2=new ActiveXObject("microsoft.XMLDOM");
    xsl2.load('laptops_xsl.xsl');//loads third stylesheet
    xsl3=new ActiveXObject("microsoft.XMLDOM");
    xsl3.load('sort_name_up_xsl.xsl');//loads fourth stylesheet
    xsl4=new ActiveXObject("microsoft.XMLDOM");
    xsl4.load('sort_name_down_xsl.xsl');//loads fifth stylesheet
    xsl5=new ActiveXObject("microsoft.XMLDOM");
    xsl5.load('sort_packages_up_xsl.xsl');//loads sixth stylesheet
    xsl6=new ActiveXObject("microsoft.XMLDOM");
    xsl6.load('sort_packages_down_xsl.xsl');//loads seventh stylesheet

    .......

    xmlt=new Array(); //declaring an array, array is created
    xmlt[0]=xml.transformNode(xsl0); //first element is created by applying xsl0 by using //transformnode function
    xmlt[1]=xml.transformNode(xsl1);
    xmlP.innerHTML=xmlt[0];//displays the extracted info stored in xml[0]
    xmlt[2]=xml.transformNode(xsl2);
    xmlt[3]=xml.transformNode(xsl3);//nameup
    xmlt[4]=xml.transformNode(xsl4);//namedown
    ......

    I'm trying to use the onChange function for the combobox

    <select name="select" size="1">
    <option onClick="changexsl(3);">items in ascending order according to:</option>
    <option onChange="changexsl(5);">name</option>
    <option onChange="changexsl(7);">package</option>
    <option onChange="changexsl(9);">cpu</option>
    <option onChange="changexsl(11);">memory</option>
    <option onChange="changexsl(13);">hard drive</option>

    but when I select any item nothing happens.

    Please Help

    getchoo
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    20
    Rep Power
    0

    oops forgot one more function


    forgot to paste this function:

    function changexsl(n) {
    xmlP.innerHTML=xmlt[n];
    }
    </SCRIPT>
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    8
    Rep Power
    0
    hello

    The onchange event is called in the select tag, not on the option tag.

    I guess this is basically how it should be done.


    <SCRIPT language="Javascript">
    <!--
    function changexsl()
    {
    var n;
    n = select1.value;
    xmlP.innerHTML=xmlt[n];
    }
    -->
    </script>


    <select name="select1" size="1" onChange="changexsl()">
    <option value="3">items in ascending order</option>
    <option value="5">name</option>
    <option value="5">name</option>
    <option value="7">package</option>
    ..
    ..
    </select>



    Reem

IMN logo majestic logo threadwatch logo seochat tools logo