Strongbad
Joined: 16 Nov 2006 Posts: 1
|
Posted: Thu Nov 16, 2006 6:35 pm Post subject: Option value input problem |
|
|
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.
| Quote: |
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.
| Quote: |
<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. |
|