-
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
-
Can you provide a page where we can see the issue?