It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Option value input problem

Option value input problem

Postby Strongbad on Thu Nov 16, 2006 5:35 pm

I'm trying to get this function working, so that when a user choose a value from the drop-down meny, the appropriate textbox is shown. To do this I'm using this script to unhide the selected area, with the div id as an in-paramterer.

function switchSearch(divID) {
var coll = document.all.tags("DIV");
if (coll != null) {
for (i=0; i<coll.length; i++) {
coll[i].style.display = "none";
}
}

meny.style.display = "";
search.style.display = "";
divID.style.display = "";
div1.style.display = "none";
}

The red code is the problem.
<div id="search">
<ul>
<form action="resultatsoek.php" method="post">

<select name="soektype" onChange="switchSearch(this.options[this.selectedIndex].value);">

<option value="div1">List alle</option>
<option value="div2">ISBN</option>
<option value="div3">Forfatter</option>
<option value="div4">Tittel</option>
<option value="div5">Eier</option>

</select><br /><br />

<div class="empty" id="div1" style="display: none">
<input name="div1" type="text"></div>

<div class="empty" id="div2" style="display: none">
<input name="div2" type="text"></div>

<div class="empty" id="div3" style="display: none">
<input name="div3" type="text"></div>

<div class="empty" id="div4" style="display: none">
<input name="div4" type="text"></div>

<div class="empty" id="div5" style="display: none">
<input name="div5" type="text"></div>

<input type="submit" value="Søk"></form>

<a href="#" onclick="javascript: switchSearch(div3);">click here to toggle</a>
</div>

The red code in the switchSearch script-function works with the "ahref-oncklick" where you insert a premade variable, but not with the red onchange dynamic script-call, even though it should give the same variable in to the script. It even shows the right value when I use document.write(divID) in the script.

Any help would be appreciated.
Strongbad
 
Posts: 0
Joined: Thu Nov 16, 2006 5:29 pm

Who is online

Users browsing this forum: No registered users and 3 guests