Modificare action la Select

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
nutzu123
Mesaje:83

Modificare action la Select

Salut! Am si eu o problema de cautarea-n site:

Cod: Selectaţi tot

<form action="search.php" method="post">
<input type="text" name="search" maxlength="40" />
<select name="alege">
<option value="">alege</option>
<option value="Muzica">Muzica</option>
<option value="Audio">Audio</option>
<option value="Video">Video</option>
</select>
<input type="submit" name="submit" value="Cauta" />
</form>	
Adica atunci cand aleg "Muzica" sa imi caute in search.php cand aleg "Audio" sa imi caute in search2.php si cand aleg "Video" sa imi caute in search3.php

Se poate asa ceva? Astept un raspuns!
Cu respect Nutzu! ;)

MarPlo Mesaje:4343
Se poate cu JavaScript, asa:

Cod: Selectaţi tot

<script type="text/javascript">
var pags = new Array();
 pags['Muzica'] = 'search.php';
 pags['Audio'] = 'search2.php';
 pags['Video'] = 'search3.php';

function changepg(val) {
  document.numf.action = pags[val];
}
</script>
<form action="search.php" method="post" name="numf">
<input type="text" name="search" maxlength="40" />
<select name="alege" onchange="changepg(this.value)">
<option value="">alege</option>
<option value="Muzica">Muzica</option>
<option value="Audio">Audio</option>
<option value="Video">Video</option>
</select>
<input type="submit" name="submit" value="Cauta" />

Subiecte similare