Results 1 to 2 of 2

Thread: niceforms

  1. #1
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default niceforms

    hi i hope someone can advise me with this ...

    im trying to use the niceforms script to create a dropdown menu like the one here:

    i have a existing dynamic dropdown form that uses this to link to the pages: <select onchange="location=this.value" size="1" >

    the onchange function has to be changed to : <select class="NFOnChange" size="1" >

    and in the javascript i have to add this :

    el.lnk._onclick = el.onclick || function () {
    if(this.ref.oldClassName == "NFOnChange") {
    location = this.value
    }};

    the problem is that the links now go to www.website.com/undefined

    here is the full code:

    Code:
    <form class="niceform">
    	 <select class="NFOnChange" size="1" >
          <option value=""><?php echo $text_select; ?></option>
          <?php foreach ($colours as $colour) { ?>
          <?php if ($colour['colour_id'] == $colour_id) { ?>
          <option value="<?php echo $colour['href']; ?>" selected="selected"><?php echo $colour['name']; ?></option>
          <?php } else { ?>
          <option value="<?php echo $colour['href']; ?>"><?php echo $colour['name']; ?></option>
          <?php } ?>
          <?php } ?>
        </select>
    </form>
    and the full js function:
    Code:
    function option(el, no) { //extend Options
    	el.li = document.createElement('li');
    	el.lnk = document.createElement('a');
    	el.lnk.href = "javascript:;";
    	el.lnk.ref = el.parentNode;
    	el.lnk.pos = no;
    	el.lnk._onclick = el.onclick || function () {};
    	el.txt = document.createTextNode(el.text);
    	el.lnk.appendChild(el.txt);
    	el.li.appendChild(el.lnk);
    
    	el.lnk._onclick = el.onclick || function () {
    if(this.ref.oldClassName == "NFOnChange") {
    location = this.value
    }}; 
    
    }
    Im not to good with javascript so i think i have to change this : location = this.value i dont know what it should be

    any advice is apperciated

    thanks

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Can you provide a page where we can see the issue?

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
  •