Jump to content

ranonymus

Members
  • Posts

    7
  • Joined

  • Last visited

ranonymus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. if i use your example i get no value
  2. so, i cant get the values in order for now like this <select style="width:160px;" name="cod_ano" onChange="autoSubmit();"> <option value="cod_ano">Selecione o Ano</option> <?php $sql = "SELECT * FROM ano"; $array1 = mysql_query($sql,$conn); while($row = mysql_fetch_array($array1)) { $val = $row['code_ano']."|".$row['nome_ano']; echo ("<option value=\"'$val'\" " . ($ano == $row["cod_ano"]? " selected" : "") . ">$row[nome_ano]</option>"); } ?> </select> but now it doens´t load the 2nd select... and i think that is because the script for cascade.... <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['theForm']; formObject.submit(); } </script>
  3. sorry i cant make it work now, could you pls make the select with your exemple?
  4. so your saying to do this <option value="cod_ano">Selecione o Ano</option> <?php $sql = "SELECT * FROM ano"; $array1 = mysql_query($sql,$conn); while($row = mysql_fetch_array($array1)) { echo ("<option value=$val = $row['code_ano']."|".$row['nomo_ano'] " . ($ano == $row["cod_ano"]? " selected" : "") . ">$row[nome_ano]</option>"); } ?> </select> is this??? and how do i get only the name?.. what if we use a script to get the text from the select instead of the value?
  5. this is what i have, much is missing... <?php $ano = null; //declare vars $conn = mysql_connect("localhost", "root", ""); $db = mysql_select_db('concrete',$conn); if(isset($_GET["cod_ano"]) && is_numeric($_GET["cod_ano"])) { $ano = $_GET["cod_ano"]; } <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['theForm']; formObject.submit(); } </script> <form id ="theForm" name="theForm" method="GET"> <div style="width:1100px; height:768px;"> <table width="1090" height="766" border="0"> <tr> <td width="600"></td> <td style="margin-top:10px;"><select style="width:160px;" name="cod_ano" onChange="autoSubmit();"> <option value="cod_ano">Selecione o Ano</option> <?php $sql = "SELECT * FROM ano"; $array1 = mysql_query($sql,$conn); while($row = mysql_fetch_array($array1)) { echo ("<option value=\"$row[cod_ano]\" " . ($ano == $row["cod_ano"]? " selected" : "") . ">$row[nome_ano]</option>"); } ?> </select> <?php if($ano!= null && is_numeric($ano)) { ?> <select style="width:260px;" name="cod_curso" onChange="autoSubmit();"> <option value="cod_curso">Selecione o curso</option> <?php $sql2 = "SELECT * FROM curso WHERE cod_ano = $ano "; $array2 = mysql_query($sql2,$conn); while($row = mysql_fetch_array($array2)) { echo ("<option value=\"$row[cod_curso]\" " . ($curso == $row["cod_curso"]? " selected" : "") . ">$row[nome_curso]</option>"); } ?> </select> <?php if($curso!= null && is_numeric($curso)) { ?> <br> <br> <select style="width:250px;" name="cod_disciplina" onChange="autoSubmit();"> <option value="cod_disciplina">Selecione a disciplina</option> <?php $sql3 = "SELECT * FROM disciplina WHERE cod_ano = $ano AND cod_curso = $curso "; $array3 = mysql_query($sql3,$conn); while($row = mysql_fetch_array($array3)) { echo ("<option value=\"$row[cod_disciplina]\" " . ($disciplina == $row["cod_disciplina"]? " selected" : "") . ">$row[nome_disciplina]</option>"); } ?> </select> <input name="formSubmit" type="submit" value="Enviar" /> <input type="reset" value="Limpar" onclick="reset()" /> </p></td> </tr> </table>
  6. like i said, if i change it the 2nd select doenst work...
  7. hello everyone, im new here and i need help to complete a job. the thing is: i need a form that pulls data from database and then after the submit button it will save it to another table. the form will have 3 selects that are connected, all of them are filled with a table info. when the first one is choosen the second one will appear and so on. also the form will have to save the text from the selects, not the value: echo ("<option value=\"$row[cod_ano]\ " . ($ano == $row["cod_ano"]? " selected" : "" ) . "> ".$row['nome_ano'] . "</option>"); i need to save the .$row['nome_ano'] but it saves the .$row['cod_ano'], and if i change it the 2nd one doenst work. this is getting my crazy allready... can any1 help??? thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.