Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di Freedom
    Registrato dal
    Jan 2003
    Messaggi
    839

    List box che non invia...

    Ciao,

    ho questo script per passare dei valori da una lista all'altra. Funziona bene a livello di script, il problema č che non invia il form. Perchč?
    codice:
    <html>
    
    <head>
    <title>Selecciona elementos en lista</title>
    <p align="center">Selecciona elementos en lista
    
    
    <!--
    This file retrieved from the JS-Examples archives
    http://www.js-examples.com
    100s of free ready to use scripts, tutorials, forums.
    Author: Jan Seda - 0
    -->
    <style>
    .inputF {
    	width=170;
    	height=150;
    	background-color:#FAFB99
    }
    .inputF2 {
    	width=170;
    	background-color:#FAFB99
    }
    .listCell{
    	background-color:#FCFE52;
    	layer-background-color: #FCFE52;
    }
    	
    .selCell {
    	background-color:#7073FE;
    	border-style:inset;
    	border-width:1px;
    	border-left-color:white;
    	border-top-color:white;
    	border-bottom-color:black;
    	border-right-color:black;
    }
    H6 {
    	COLOR: white; FONT-FAMILY: Arial,  helvetica CE, helvetica; FONT-SIZE: 8pt; FONT-STYLE: normal; FONT-WEIGHT: normal
    }
    TABLE {
    	COLOR: black;
    	FONT-FAMILY: Arial,  helvetica CE, helvetica;
    	FONT-SIZE: 9pt;
    	FONT-STYLE: normal;
    	FONT-WEIGHT: normal;
    	display: block;
    }
    SELECT {
    	COLOR: black; FONT-FAMILY: Arial,  helvetica CE, helvetica; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-WEIGHT: normal;
    }
    </style>
    <script LANGUAGE="JavaScript">
    <!--
    
    function moveVals(n, from, to) {
    	if (document.layers) {
    		fromObj = document.layers[from];
    		to = document.layers[to];
    	} else if (document.all) {
    		fromObj = document.all(from);
    		to = document.all(to);
    	}
    	if (n == 1 || n == 2) {
    		var indTo = to.length-1;
    		for (i=fromObj.length-1; i>=0; i--) {
    			if (n==1 || fromObj.options[i].selected) {
    				indTo++;
    				to.options[indTo] = new Option(fromObj.options[i].text, fromObj.options[i].value);
    				fromObj.options[i] = null;
    			}
    		}
    	} else if (n == 3 || n == 4) {
    		var indFrom = fromObj.length-1;
    		for (i=to.length-1; i>=0; i--) {
    			if (n==4 || to.options[i].selected) {
    				indFrom++;
    				fromObj.options[indFrom] = new Option(to.options[i].text, to.options[i].value);
    				to.options[i] = null;
    			}
    		}
    	}
    }
    
    function frmButtons() {
    	var select = "chosen";
    	var avail = "avail";
    	if (document.layers) {
    		var sel = document.layers[select];
    		var av = document.layers[avail];
    	} else if (document.all) {
    		var sel = document.all(select);
    		var av = document.all(avail);
    	}
    	if (sel.length <= 0) {
    		document.frmAddPro.btnR.disabled = true;
    		document.frmAddPro.btnRR.disabled = true;
    	} else {
    		document.frmAddPro.btnR.disabled = false;
    		document.frmAddPro.btnRR.disabled = false;
    	}
    	if (av.length <= 0) {
    		document.frmAddPro.btnL.disabled = true;
    		document.frmAddPro.btnLL.disabled = true;
    	} else {
    		document.frmAddPro.btnL.disabled = false;
    		document.frmAddPro.btnLL.disabled = false;
    	}
    }
    
    function deleteFrom() {
    	for (i=0; i<document.frmAddPro.elements.length-1; i++) {
    		if  (document.frmAddPro.elements[i].tagName.indexOf("SELECT") && document.frmAddPro.elements[i].id.indexOf("av")) {
    			alert("Cislo: "+i+" Name: "+document.frmAddPro.elements[i].tagName);
    		}
    	}
    }
    -->
    </script>
    </head>
    
    
    
    <body>
    
    </p>
    
    <center>
    <form NAME="frmAddPro">
      <table height="172">
        <tr>
          <td WIDTH="170" CLASS="selCell" style="background-color: #FFFFFF" height="14">
          Ciudades disponibles:</td>
          <td bgcolor="#FFFFFF" height="14"></td>
          <td WIDTH="170" CLASS="selCell" style="background-color: #FFFFFF" height="14">
          Tu favorita:</td>
        </tr>
        <tr>
          <td height="150"><select MULTIPLE CLASS="inputF" NAME="avail" ID="av">
          <option>Berlín</option>
          <option>Londres</option>
          <option>Luxemburgo</option>
          <option>Nueva York</option>
          <option>Paris</option>
          <option>Praga</option>
          <option>Tokyo</option>
          </select> </td>
          <td ALIGN="CENTER" VALIGN="CENTER" height="150">
          <input TYPE="button" VALUE="&gt;&gt;" STYLE="{width=25;}" NAME="btnLL" onClick="javascript: moveVals(1, 'avail', 'chosen'); frmButtons(); return false;">
    
          <input TYPE="button" VALUE="&gt;" STYLE="{width=25;}" NAME="btnL" onClick="javascript: moveVals(2, 'avail', 'chosen'); frmButtons(); return false;">
    
          <input TYPE="button" VALUE="&lt;" STYLE="{width=25;}" NAME="btnR" onClick="javascript: moveVals(3, 'avail', 'chosen'); frmButtons(); return false;">
    
          <input TYPE="button" VALUE="&lt;&lt;" STYLE="{width=25;}" NAME="btnRR" onClick="javascript: moveVals(4, 'avail', 'chosen'); frmButtons(); return false;">
          </td>
          <td height="150"><select MULTIPLE CLASS="inputF" NAME="chosen"></select>
          </td>
        </tr>
      </table>
    </form>
    </center>
    
    Special permission was granted to JS-X to present this script here
    <script>
    frmButtons();
    </script>
    </h6>
    <h6></h6>
    
    </body>
    
    </html>
    Sicut Nox Silentes

  2. #2
    Utente di HTML.it L'avatar di Freedom
    Registrato dal
    Jan 2003
    Messaggi
    839
    Nessuno sa come poter risolvere?
    Sicut Nox Silentes

  3. #3
    Utente di HTML.it L'avatar di Freedom
    Registrato dal
    Jan 2003
    Messaggi
    839
    Grazie ugualmente...
    Sicut Nox Silentes

  4. #4
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Io non vedo il submit nello script, ma non sapendo cosa fa esattamente non saprei neanche dove metterlo per facilitare metti un link pubblico e spiega quando vuoi che venga spedito il form.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  5. #5
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Originariamente inviato da Freedom
    Grazie ugualmente...

    Non ringraziare Io ti consiglio di cambiare codice. Penso che chiunque qui ti possa consigliare qualcosa di meglio. Ma vediamo dove č l'errore:



    fromObj.options[indFrom] = new Option(to.options[i].text, to.options[i].value);

    quando popoli il secondo DropDown chosen, il codice crea gli elementi copiandoli da avail.
    La proprietā text č valorizzata, mentre la proprietā value č sempre "". Quando tu spedisci, spedisci i value selezionati ossia tanti "" separati da virgole.

    La soluzione č quella di scrivere codice corretto come da esempio:

    codice:
    <select multiple class="inputF" name="avail" id="av">
    	<option value="Berlin">Berlín</option>
    	<option value="Londres">Londres</option>
    	<option value="Luxemburto">Luxemburgo</option>
    	<option value="Nueva York">Nueva York</option>
    	<option value="Paris">Paris</option>
    	<option value="Praga">Praga</option>
    	<option value="Tokyo">Tokyo</option>
    </select>
    In altri termini, il DropDown deve avere la proprietā value e la proprietā text valorizzati.



    ps. naturalmente devi mettere un pulsante di submit. Il codice funziona solo con IE (l'ho provato con IE8). Non va nč con Fierefox, nč con Opera. Insomma, č sabbia negli occhi
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.