Nieuw lid |
|
Met dit kleine systeem onderdeel kun je vanuit een dropdownmenu text uit een database in een textarea plaatsen, automatisch.
Maar ik heb een javascriptfout die ik maar niet kan vinden.
Regel: 11
Teken: 1
Fout: Object wordt verwacht
Code:0
<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<?
$conn = mysql_connect("localhost","bla","xxx");
mysql_select_db("contract",$conn);
$i=1;
$sql9 = "SELECT * FROM prijsafspraken ORDER BY id";
$result9 = mysql_query($sql9,$conn) or die("Error: $sql9".mysql_error());
while ($result2 = mysql_fetch_row($result9)){
$prijsafspraken[$i] = $result2;
$i++;
}
$i=0;
$sql2 = "select prijsafspraken from contractregelopties where id=72";
$result2 = mysql_query($sql2,$conn) or die("Error: $sql2".mysql_error());
while ($result3 = mysql_fetch_row($result2)){
$prijs[$i] = $result3;
$i++;
}
echo "<table>\n";
echo "<tr class=regel2>\n";
echo "<td valign=top>Prijs afspraken</td>\n";
echo "<TD valign=top>\n";
echo "<form name=contractregeloptie>\n";
echo "<select class=\"navi\" name=\"example\" size=\"1\" onChange=\"showtext2()\">\n";
echo "<option value=\"0\">Laatste invoer</option>\n";
for($i=1;$i<=count($prijsafspraken);$i++)
{
echo "<option value=";
echo '"'.$prijsafspraken[$i][0].'"';
echo ">".$prijsafspraken[$i][1]."</option>";
echo "\n";
}
echo "</select><br>\n";
?> <textarea name="prijs" rows="4" cols="30" wrap="virtual" class="navi"></textarea>
<script language="text/javascript">
<!--
var shortcut=document.contractregeloptie;
var descriptions2=new Array();
<? for($i=0;$i<count($prijs);$i++){
echo "descriptions2[0]=";
echo '"'.$prijs[$i][0].'"';
echo "\n";
}
for($i=1;$i<=count($prijsafspraken);$i++){
echo "descriptions2[$i]=";
echo '"'.$prijsafspraken[$i][2].'"';
echo "\n";
}?>
function showtext2(){
shortcut.prijs.value=descriptions2[shortcut.example.selectedIndex]
}
//-->
<?
echo "</script>\n";
echo "</form>\n";
echo "</TD>\n";
echo "</tr>\n";
echo "</table>\n";
?></BODY>
</HTML>
<HTML> <HEAD> <TITLE>test</TITLE> </HEAD> <BODY> <? $i=1; $sql9 = "SELECT * FROM prijsafspraken ORDER BY id"; $prijsafspraken[$i] = $result2; $i++; } $i=0; $sql2 = "select prijsafspraken from contractregelopties where id=72"; $prijs[$i] = $result3; $i++; } echo "<tr class=regel2>\n"; echo "<td valign=top>Prijs afspraken</td>\n"; echo "<TD valign=top>\n"; echo "<form name=contractregeloptie>\n"; echo "<select class=\"navi\" name=\"example\" size=\"1\" onChange=\"showtext2()\">\n"; echo "<option value=\"0\">Laatste invoer</option>\n"; for($i=1;$i<=count($prijsafspraken);$i++) { echo '"'.$prijsafspraken[$i][0].'"'; echo ">".$prijsafspraken[$i][1]."</option>"; } ?> <textarea name="prijs" rows="4" cols="30" wrap="virtual" class="navi"></textarea> <script language="text/javascript"> <!-- var shortcut=document.contractregeloptie; var descriptions2=new Array(); <? for($i=0;$i<count($prijs);$i++){ echo "descriptions2[0]="; echo '"'.$prijs[$i][0].'"'; } for($i=1;$i<=count($prijsafspraken);$i++){ echo "descriptions2[$i]="; echo '"'.$prijsafspraken[$i][2].'"'; }?> function showtext2(){ shortcut.prijs.value=descriptions2[shortcut.example.selectedIndex] } //--> <? ?></BODY> </HTML>
/////////////////////////////////////////////////////////////
broncode
<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<table>
<tr class=regel2>
<td valign=top>Prijs afspraken</td>
<TD valign=top>
<form name=contractregeloptie>
<select class="navi" name="example" size="1" onChange="showtext2()">
<option value="0">Laatste invoer</option>
<option value="2">test</option>
<option value="3">prijs2</option>
<option value="4">prijs3</option>
</select><br>
<textarea name="prijs" rows="4" cols="30" wrap="virtual" class="navi"></textarea>
<script language="text/javascript">
<!--
var shortcut=document.contractregeloptie;
var descriptions2=new Array();
descriptions2[0]="prijs"
descriptions2[1]="test
test"
descriptions2[2]="prijsafspraak2"
descriptions2[3]="prijsafsrpaak3"
function showtext2(){
shortcut.prijs.value=descriptions2[shortcut.example.selectedIndex]
}
//-->
</script>
</form>
</TD>
</tr>
</table>
</BODY>
</HTML>
<HTML> <HEAD> <TITLE>test</TITLE> </HEAD> <BODY> <table> <tr class=regel2> <td valign=top>Prijs afspraken</td> <TD valign=top> <form name=contractregeloptie> <select class="navi" name="example" size="1" onChange="showtext2()"> <option value="0">Laatste invoer</option> <option value="2">test</option> <option value="3">prijs2</option> <option value="4">prijs3</option> </select><br> <textarea name="prijs" rows="4" cols="30" wrap="virtual" class="navi"></textarea> <script language="text/javascript"> <!-- var shortcut=document.contractregeloptie; var descriptions2 =new Array(); descriptions2[0]="prijs" descriptions2[1]="test test" descriptions2[2]="prijsafspraak2" descriptions2[3]="prijsafsrpaak3" function showtext2(){ shortcut.prijs.value=descriptions2[shortcut.example.selectedIndex] } //--> </script> </form> </TD> </tr> </table> </BODY> </HTML>
http://members.lycos.nl/sjemmie5/test11.php
|