39 users online (0 members and 39 guests)  


  Results 1 to 4 of 4

Related

  1. how to stop javascript via another javascript    Forum: Javascript Forum
    Replies: 0
  2. style jumpMenu arrow with css    Forum: CSS Forum
    Replies: 2
  3. Replies: 5
  4. alter affiliate program code    Forum: HTML Forum
    Replies: 3
  1. #1
    grassmeyerdesign's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    8

    Question Alter javascript NiceForms to work with JumpMenu

    I need help with altering this code:
    http://www.badboy.ro/articles/2005-07-23/niceforms_preview/

    Right now it does not work with a JumpMenu.
    The only way to get this to work is to place the "form element" within a form tag.

    This is what I am trying to do, here is the original code to which I am trying to add niceforms styling to:
    HTML Code:
    <select name="lang" id="mySelect2" onchange="jumpMenu('parent',this,0)" class="width_155">
    <!-- BEGIN: option -->
    <option value="index.php?_g=sw&amp;r={VAL_CURRENT_PAGE}&amp;currency={VAL_CURRENCY}" {CURRENCY_SELECTED}>{CURRENCY_NAME}</option><!-- END: option -->
    </select>

    The only way that I have found to get the styling to be applied to the above drop down menu is to use this code:
    HTML Code:
    <form  class="niceform" >
    <select name="lang" id="mySelect2" onchange="jumpMenu('parent',this,0)" class="width_155">
    <!-- BEGIN: option -->
    <option value="index.php?_g=sw&amp;r={VAL_CURRENT_PAGE}&amp;currency={VAL_CURRENCY}" {CURRENCY_SELECTED}>{CURRENCY_NAME}</option><!-- END: option -->
    </select>
    </form>
    I have tried adding class="niceform" to the select tag but it doesn't work, the class must be added to <form>. But then the jumpMenu doesn't work, meaning it doesn't switch the page upon selecting an item from the list . . .

    Can someone help with this?

    I'm a newbie at altering javascript but I think that this is what needs to be changed:

    from niceforms.js
    Code:
    var niceforms = document.getElementsByTagName('form');
    does the TagName need to be div or select?

    I'm going to do trial and error to figure this out but if someone could help that would be great!!

    Jen

  2. #2
    grassmeyerdesign's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    8

    Re: Alter javascript NiceForms to work with JumpMenu

    What I've tried:

    I tried adding the class to a div that surrounds the select function and changed the js line to
    Code:
    ('div')
    That didn't work. So I tried adding the class to the select tag and changed the js line to
    Code:
    ('select')
    That didn't work either . . . any help here would be appreciated much!

  3. #3
    grassmeyerdesign's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    8

    Re: Alter javascript NiceForms to work with JumpMenu

    This is the jumpMenu code

    Code:
    function jumpMenu(target, object, restore) { 
        eval(target+".location='"+object.options[object.selectedIndex].value+"'");
        if (restore) object.selectedIndex=0;
    
    }

  4. #4
    grassmeyerdesign's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    8

    Re: Alter javascript NiceForms to work with JumpMenu

    I've found a couple of instructions and I'm not sure if they are relevant, I have tried applying them but I'm really not sure if I am doing it correctly. Here are the instructions.

    Here’s now to make onchange work correctly in select lists:
    In niceforms.js find the function ’selectMe’ (near line 268)
    AFTER selectField=[…] add:
    //save original value for onchange event
    value = selectField.value;
    AFTER textVar.replaceChild[…] add:
    //fire the onchange event
    if(value!=selectField.value) {eval(selectField.getAttribute(”onchange”).replace(/this.value/g, selectField.value));}
    Another option:
    problem with onchange or onclick: Add after:
    ————————— optionsDiv.appendChild(optionHolder);
    ———————————————
    This:
    ———————————————
    if(selects[q].onchange){
    optionLink.onclick=selects[q].onchange;
    }else if(selects[q].onclick){
    optionLink.onclick=selects[q].onclick;
    }
    And that function to your js:
    function onChanged(){
    document.FORMNAME.submit();
    }

    Is anyone available to help with this?