Salve, sto sbattendo la testa su un problema da qualche giorno ed ho deciso di chiedere in questo forum che consulto spesso
In un div devo mostrare degli elementi (namelist) relativi all'id_event=5. Fin qui tutto ok, però ho intenzione di creare un pulsante per ogni elemento caricato che mi permetta di modificarne dei campi.
Ecco il codice per la visualizzazione delle liste:
Codice PHP:
<?php
$id_event=5; $query="select namelist from ev_lists where idevent= '$id_event'";
$sql= mysql_query($query); $num = mysql_num_rows($sql);
while($row = mysql_fetch_array($sql)){ $namelist = $row['namelist'];
echo"<form name='orderform'> <input type='radio' name='setlist' value='$namelist'>".$namelist."
";
}
echo"<input type='submit' onclick=' setCheckedValue()'></form>";
?>
Ecco invece la parte relativa all'inserimento del valore dentro al record selezionato prima:
codice:
<form id="form1" name="form1" method="post" action="index.php">
<table width="184" height="150" border="0" cellpadding="0">
<tr>
<td colspan="3"><input type="text" name="textfield" id="textfield" /></td>
</tr>
<tr>
<td width="58"><input name="1" type="button" value="1" onclick="mark('1')"/></td>
<td width="58"><input name="2" type="button" value="2" onclick="mark('2')"/></td>
<td width="58"><input name="3" type="button" value="3" onclick="mark('3')"/></td>
</tr>
<tr>
<td><input name="4" type="button" value="4" onclick="mark('4')"/></td>
<td><input name="5" type="button" value="5" onclick="mark('5')"/></td>
<td><input name="6" type="button" value="6" onclick="mark('6')"/></td>
</tr>
<tr>
<td><input name="7" type="button" value="7" onclick="mark('7')"/></td>
<td><input name="8" type="button" value="8" onclick="mark('8')"/></td>
<td><input name="9" type="button" value="9" onclick="mark('9')"/></td>
</tr>
<tr>
<td height="35" colspan="2"><input name="0" type="button" class="input0" value="0" onclick="mark('0')"/></td>
<td><input name="<-" type="button" value="<-" onclick="mark('Confermi?')"/></td>
</tr>
</table>
<table width="185" height="44" border="0">
<tr>
<td><input name="submit" type="submit" value="Conferma" class="confcanc"/></td>
<td><input name="cancel" type="reset" value="Canc" class="confcanc" /></td>
</tr>
</table>
</form>
<form action="index.php" method="get" target="_self">
Ecco la parte in js:
codice:
<script type="text/javascript">
<!--
function mark(tipo) {
document.getElementById("textfield").value = document.getElementById("textfield").value + tipo;
}
function setCheckedValue(setlist, lista) {
if(!setlist)
return;
var radioLength = setlist.length;
if(radioLength == undefined) {
setlist.checked = (setlist.value == lista.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
setlist[i].checked = false;
if(setlist[i].value == newValue.toString()) {
setlist[i].checked = true;
}
}
}
-->
</script>
Praticamente questa definizione funziona:
$list=$_GET['setlist'];
Quando faccio ad esempio echo $list; funziona, quando invece devo andare a specificare il where $list no, ma scrive il valore in un record senza una namelist.
Cosa posso fare? Grazie anticipatamente