24. marts 2013 - 17:43
Der er
7 kommentarer
Hent data via value i select til text felt..
hej.. fik lidt hjælp et andet sted fra men vi fik det aldrig til at funge, så håber der er nogen som kan hjælpe.. når man vælge noget i select boxen skal den via den value som den har så gå ind i databasen og finde en pris ud fra den value, og så skrive den i text feltet.. <?php include("connect.php"); $liftnr = mysql_query("SELECT * FROM Lift ORDER BY liftnr ASC"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Lift</title> <script> function showpris(str, id){ if (str==""){ document.getElementById(id).value=""; return; } if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(id).value=xmlhttp.responseText; } } xmlhttp.open("GET","getpris.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <?php $idno = 1; $dato = date("Y-m-d"); while($rowlift = mysql_fetch_assoc($liftnr)) if($rowlift['dato'] == $dato) { ?> <table border='1'> <?PHP echo "<form action='opretlift.php?id=".$rowlift['id']."' method='post'>"; ?> <tr> <td width="67">Lift</td> <td width="250">Springer</td> <td width="129">Højde</td> <td>Pris</td> <td width="217">Kommentar</td> </tr> <tr> <td width="67" rowspan="5" align="center"> <?php echo "<font size='+6' color='#000000'>".$rowlift['liftnr']."</font>"; ?></td> <td><select name="s1" style="width:250px"> <?php echo "<option value=".$rowlift['Springer1'].">".$rowlift['Springer1']."</option>"; $query = mysql_query("SELECT * FROM brugere ORDER BY Navn ASC"); while($row = mysql_fetch_assoc($query)){ if($row['nick'] != '') echo "<option value=".$row['Navn'].">".$row['nick']." (".$row['klub'].")</option>"; else echo "<option value=".$row['Navn'].">".$row['Navn']. "</option>"; } ?> </select> </td> <td> <?php echo "<select name='sel1' onchange='showpris(this.value, '".$idno.$rowlift['p1']."');'>"; $hojde1 = mysql_query("SELECT * FROM priser WHERE id='".$rowlift['H1']."'"); $rowH1 = mysql_fetch_assoc($hojde1); echo "<option value=".$rowlift['H1'].">".$rowH1['hojde']."</option>"; $pris = mysql_query("SELECT * FROM priser ORDER BY id ASC"); while($rowP = mysql_fetch_assoc($pris)){ echo "<option value='".$rowP['id']."'>".$rowP['hojde']. "</option>"; } echo "</select>" ?> </td> <td><input type='text' id='<?php $idno.$rowlift['p1'];?>' name=' "p1' <?php if($rowlift['p1'] != ''){echo "value='".$rowlift['p1']."'";}?>></td> <td><input type="text" name="kommentar1" width="217"></td> </tr> <tr> <td><select name="s2" style="width:250px"> <?php $query = mysql_query("SELECT * FROM brugere ORDER BY Navn ASC"); echo "<option value=".$rowlift['Springer2'].">".$rowlift['Springer2']."</option>"; while($row = mysql_fetch_assoc($query)){ echo "<option value=".$row['Navn'].">".($row['nick'] != '' ? '' : ''); } ?> </select> </td> <td> <?php echo "<select name='sel2' onchange='showpris(this.value, '".$idno."pris2');'>"; $hojde2 = mysql_query("SELECT * FROM priser WHERE id='".$rowlift['H2']."'"); $rowH2 = mysql_fetch_assoc($hojde2); echo "<option value=".$rowlift['H2'].">".$rowH2['hojde']."</option>"; $pris = mysql_query("SELECT * FROM priser ORDER BY id ASC"); while($rowP = mysql_fetch_assoc($pris)){ echo "<option value='".$rowP['id']."'>".$rowP['hojde']. "</option>"; echo "</select>"; } ?></td> <td> <?php if($rowlift['p2'] != '') echo "<input type='text' id='".$idno."pris2' name='p2' value='".$rowlift['p2']."'>"; else echo "<input type='text' id='".$idno."pris2' name='p2'>" ?></td> <td><input type="text" name="kommentar2" width="217"></td> </tr> <tr> <td> <select name="s3" style="width:250px"> <?php $query = mysql_query("SELECT * FROM brugere ORDER BY Navn ASC"); echo "<option value=".$rowlift['Springer3'].">".$rowlift['Springer3']."</option>"; while($row = mysql_fetch_assoc($query)){ if($row['nick'] != '') echo "<option value=".$row['Navn'].">".$row['nick']. "</option>"; else echo "<option value=".$row['Navn'].">".$row['Navn']. "</option>"; } ?></select></td> <td> <?php echo "<select name='sel3' onchange='showpris(this.value, '".$idno."pris3');'>"; $hojde3 = mysql_query("SELECT * FROM priser WHERE id='".$rowlift['H3']."'"); $rowH3 = mysql_fetch_assoc($hojde3); echo "<option value=".$rowlift['H3'].">".$rowH3['hojde']."</option>"; $pris = mysql_query("SELECT * FROM priser ORDER BY id ASC"); while($rowP = mysql_fetch_assoc($pris)) echo "<option value='".$rowP['id']."'>".$rowP['hojde']. "</option>"; echo "</select>" ?></td> <td> <?php if($rowlift['p3'] != '') echo "<input type='text' id='".$idno."pris3' name='p3' value='".$rowlift['p3']."'>"; else echo "<input type='text' id='".$idno."pris3' name='p3'>" ?></td> <td><input type="text" name="kommentar3" width="217"></td> </tr> <tr> <td> <select name="s4" style="width:250px"> <?php $query = mysql_query("SELECT * FROM brugere ORDER BY Navn ASC"); echo "<option value=".$rowlift['Springer4'].">".$rowlift['Springer4']."</option>"; while($row = mysql_fetch_assoc($query)){ if($row['nick'] != '') echo "<option value=".$row['Navn'].">".$row['nick']. "</option>"; else echo "<option value=".$row['Navn'].">".$row['Navn']. "</option>"; } ?> </select></td> <td> <?php echo "<select name='sel4' onchange='showpris(this.value, '".$idno."pris4');'>"; $hojde4 = mysql_query("SELECT * FROM priser WHERE id='".$rowlift['H4']."'"); $rowH4 = mysql_fetch_assoc($hojde4); echo "<option value=".$rowlift['H4'].">".$rowH4['hojde']."</option>"; $pris = mysql_query("SELECT * FROM priser ORDER BY id ASC"); while($rowP = mysql_fetch_assoc($pris)) echo "<option value='".$rowP['id']."'>".$rowP['hojde']. "</option>"; echo "</select>" ?></td> <td> <?php if($rowlift['p4'] != '') echo "<input type='text' id='".$idno."pris4' name='p4' value='".$rowlift['p4']."'>"; else echo "<input type='text' id='".$idno."pris4' name='p4'>" ?></td> <td><input type="text" name="kommentar4" width="217"></td> </tr> <tr> <td> <select name="s5" style="width:250px"> <?php $query = mysql_query("SELECT * FROM brugere ORDER BY Navn ASC"); echo "<option value=".$rowlift['Springer5'].">".$rowlift['Springer5']."</option>"; while($row = mysql_fetch_assoc($query)){ if($row['nick'] != '') echo "<option value=".$row['Navn'].">".$row['nick']. "</option>"; else echo "<option value=".$row['Navn'].">".$row['Navn']. "</option>"; } ?> </select></td> <td> <?php echo "<select name='sel5' onchange='showpris(this.value, '".$idno."pris5');'>"; $hojde5 = mysql_query("SELECT * FROM priser WHERE id='".$rowlift['H5']."'"); $rowH5 = mysql_fetch_assoc($hojde5); echo "<option value=".$rowlift['H5'].">".$rowH5['hojde']."</option>"; $pris = mysql_query("SELECT * FROM priser ORDER BY id ASC"); while($rowP = mysql_fetch_assoc($pris)) echo "<option value='".$rowP['id']."'>".$rowP['hojde']. "</option>"; echo "</select>" ?></td> <td> <?php if($rowlift['p5'] != '') echo "<input type='text' id='".$idno."pris5' name='p5' value='".$rowlift['p5']."'>"; else echo "<input type='text' id='".$idno."pris5' name='p5'>" ?></td> <td><input type="text" name="kommentar5" width="217"></td> </tr> <tr> <td colspan="5" height="1"><input type="submit" value="Opdatere"></form></td> </tr> </table> <?php if($rowlift['lettet'] > 1); echo "<form action='lettet.php?id=".$rowlift['id']."' method='post'>"; echo "<input type='submit' value='Lettet'>"; echo "</form>"; ?> <br> <?php $idno++;}?> <form action="pluslift.php" method="post"> <input type="submit" value="Tilføj næste lift"> </form> </body> </html>
Annonceindlæg fra Visma Enterprise
24. marts 2013 - 18:16
#1
<ole> Hvad sker der - og hvad sker der ikke? Får du fejl? Er fejlmeldinger slået til i PHP? Kikker du efter JavaScript fejl i din browsers uviklerværktøjer? Hvad siger evt. fejl? /mvh </bole>
24. marts 2013 - 18:19
#2
- og hvordan ser den udskrevne HTML-kode ud?
24. marts 2013 - 20:01
#3
sådan ser html koden ud. <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Lift</title> <script> function showpris(str, id){ if (str==""){ document.getElementById(id).value=""; return; } if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(id).value=xmlhttp.responseText; } } xmlhttp.open("GET","getpris.php?q="+str,true); xmlhttp.send(); } </script> <script type="text/javascript" src="chrome-extension://bfbmjmiodbnnpllbbbfblcplfjjepjdn/js/injected.js"></script><style type="text/css"></style><style type="text/css"></style></head> <body> <table border="1"> <form action="opretlift.php?id=99" method="post"></form> <tbody><tr> <td width="67">Lift</td> <td width="250">Springer</td> <td width="129">Højde</td> <td>Pris</td> <td width="217">Kommentar</td> </tr> <tr> <td width="67" rowspan="5" align="center"> <font size="+6" color="#000000">1</font></td> <td><select name="s1" style="width:250px"> <option value=""></option><option value="Ali">Ali (MFK)</option><option value="Anette">bodil (MFK)</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel (MFK)</option><option value="Niels" hoeegmark="">nieller (MFK)</option></select> </td> <td> <select name="sel1" onchange="showpris(this.value, " 1');=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select> </td> <td><input type="text" id="" name=" "p1"></td> <td><input type="text" name="kommentar1" width="217"></td> </tr> <tr> <td><select name="s2" style="width:250px"> <option value=""></option><option value="Ali"></option><option value="Anette"></option><option value="Henning"></option><option value="Mikkel" rasmussen=""></option><option value="Niels" hoeegmark=""></option></select> </td> <td> <select name="sel2" onchange="showpris(this.value, " 1pris2');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="1pris2" name="p2"></td> <td><input type="text" name="kommentar2" width="217"></td> </tr> <tr> <td> <select name="s3" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel3" onchange="showpris(this.value, " 1pris3');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="1pris3" name="p3"></td> <td><input type="text" name="kommentar3" width="217"></td> </tr> <tr> <td> <select name="s4" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel4" onchange="showpris(this.value, " 1pris4');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="1pris4" name="p4"></td> <td><input type="text" name="kommentar4" width="217"></td> </tr> <tr> <td> <select name="s5" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel5" onchange="showpris(this.value, " 1pris5');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="1pris5" name="p5"></td> <td><input type="text" name="kommentar5" width="217"></td> </tr> <tr> <td colspan="5" height="1"><input type="submit" value="Opdatere"></td> </tr> </tbody></table> <form action="lettet.php?id=99" method="post"><input type="submit" value="Lettet"></form><br> <table border="1"> <form action="opretlift.php?id=100" method="post"></form> <tbody><tr> <td width="67">Lift</td> <td width="250">Springer</td> <td width="129">Højde</td> <td>Pris</td> <td width="217">Kommentar</td> </tr> <tr> <td width="67" rowspan="5" align="center"> <font size="+6" color="#000000">2</font></td> <td><select name="s1" style="width:250px"> <option value=""></option><option value="Ali">Ali (MFK)</option><option value="Anette">bodil (MFK)</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel (MFK)</option><option value="Niels" hoeegmark="">nieller (MFK)</option></select> </td> <td> <select name="sel1" onchange="showpris(this.value, " 2');=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select> </td> <td><input type="text" id="" name=" "p1"></td> <td><input type="text" name="kommentar1" width="217"></td> </tr> <tr> <td><select name="s2" style="width:250px"> <option value=""></option><option value="Ali"></option><option value="Anette"></option><option value="Henning"></option><option value="Mikkel" rasmussen=""></option><option value="Niels" hoeegmark=""></option></select> </td> <td> <select name="sel2" onchange="showpris(this.value, " 2pris2');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="2pris2" name="p2"></td> <td><input type="text" name="kommentar2" width="217"></td> </tr> <tr> <td> <select name="s3" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel3" onchange="showpris(this.value, " 2pris3');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="2pris3" name="p3"></td> <td><input type="text" name="kommentar3" width="217"></td> </tr> <tr> <td> <select name="s4" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel4" onchange="showpris(this.value, " 2pris4');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="2pris4" name="p4"></td> <td><input type="text" name="kommentar4" width="217"></td> </tr> <tr> <td> <select name="s5" style="width:250px"> <option value=""></option><option value="Ali">Ali</option><option value="Anette">bodil</option><option value="Henning">Henning</option><option value="Mikkel" rasmussen="">Meggel</option><option value="Niels" hoeegmark="">nieller</option></select></td> <td> <select name="sel5" onchange="showpris(this.value, " 2pris5');'=""><option value=""></option><option value="1">1000m</option><option value="2">1200m</option><option value="3">1500m</option><option value="4">2000m</option><option value="5">2250m</option><option value="6">2500m</option><option value="7">3000m</option><option value="8">3500m</option><option value="9">4000m</option><option value="10">Elev man.</option><option value="11">Elev auto</option><option value="12">HM</option><option value="13">Tandem pass u/video</option><option value="14">Tandem håndhold video</option><option value="15">Tandem pass m/video</option><option value="16">Tandem master</option><option value="17">Tandem video</option></select></td> <td> <input type="text" id="2pris5" name="p5"></td> <td><input type="text" name="kommentar5" width="217"></td> </tr> <tr> <td colspan="5" height="1"><input type="submit" value="Opdatere"></td> </tr> </tbody></table> <form action="lettet.php?id=100" method="post"><input type="submit" value="Lettet"></form><br> <form action="pluslift.php" method="post"> <input type="submit" value="Tilføj næste lift"> </form> </body></html>
24. marts 2013 - 20:36
#4
- og?
25. marts 2013 - 01:37
#5
Kender du den om fyren der kørte ned til sin mekaniker, sagde "reperere min bil" og gik. Vi har jo ikke en chance for at vi hvad vi skal lede efter. Det eneste jeg kan fortælle er at du bestemt ikke har styr på dine quotes.
25. marts 2013 - 02:25
#6
#5: Præcis, og der burde derfor være observeret nogle fejl fra SELECT elementernes handlers *o)
25. marts 2013 - 02:27
#7
- og man kan sådan set bare kopiere koden fra #3 ind i en editor med syntaksfarvning. Så er det ret tydeligt, hvor det går galt =)
Vi tilbyder markedets bedste kurser inden for webudvikling