Menu tartalmabol tombot kell csinalni
Adott a kovetkezo kod:A fenti kodnak az eredmenye a kovetkezo kepen lathato: klik ide
Szoval van ket menu. Az elso menu tartalmaza az osszes felhasznalot az adatbazisbol. A masodik menu pedig ures.
Ha atrakok peldaul ket felhasznalot : Zoli, Paul a masodik menube es rakatintok a submit gombra, szeretnek egy tombot csinalni, hogy a ket
felhasznalot hoza tudjam adni kesobb egy user2groups mySQL tablahoz.
Csak arra lennek kivancsi, hogyan tudok a masodik menubol egy tombot csinalni.
Ahogy latszik a masodik menu kodja HTML-ben a kovetkezo (meg akkor is ha atraktam ket usert):Kerek egy kis segitseget, elege neheznek tunik nekem a dolog, es kezdo vagyok. Mit kene modositanom, hogy a masodik menube atrakot nevekbol tombot csinaljak ?
  
 ■ 
<?php
// Connect and select the database
require('../includes/mysql.php'); 
$users = mysql_query("SELECT user_id, username FROM register");
?> 
<script language="JavaScript" type="text/javascript">
<!--
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}
function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}
function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}
//-->
</script>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table width="207" border="0">
 <tr>
  <td width="100">
    <select name="sel1" size="10" multiple="multiple" style="width: 100px">
    <?php
    while ($row = mysql_fetch_array($users)) {
    print "<option value=\"{$row['user_id']}\">{$row['username']}</option>\n";
    } ?>
    </select>
  </td>
  <td width="48" align="center" valign="middle">  
    <input type="button" value="-->" onclick="moveOptions(this.form.sel1, this.form.sel2);" />
    <input type="button" value="<--" onclick="moveOptions(this.form.sel2, this.form.sel1);" />
  </td>
  <td width="45">
    <select name="sel2" size="10" multiple="multiple" style="width: 100px">
    </select>
  </td>
  </tr>
</table>
<input type="submit" name="submit" value="submit" />
</form>Szoval van ket menu. Az elso menu tartalmaza az osszes felhasznalot az adatbazisbol. A masodik menu pedig ures.
Ha atrakok peldaul ket felhasznalot : Zoli, Paul a masodik menube es rakatintok a submit gombra, szeretnek egy tombot csinalni, hogy a ket
felhasznalot hoza tudjam adni kesobb egy user2groups mySQL tablahoz.
Csak arra lennek kivancsi, hogyan tudok a masodik menubol egy tombot csinalni.
Ahogy latszik a masodik menu kodja HTML-ben a kovetkezo (meg akkor is ha atraktam ket usert):
<select name="sel2" size="10" multiple="multiple" style="width: 100px">
</select>
 
     



JS trükközés?