Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente bannato
    Registrato dal
    Sep 2000
    Messaggi
    214

    Javascript che non va

    [i]<script language="JavaScript1.1">

    function checkrequired(which){

    var pass=true

    if (document.images){

    for (i=0;i<which.length;i++){

    var tempobj=which.elements

    if (tempobj.name.substring(0,8)=="required"){

    if (((tempobj.type=="text"||tempobj.type=="textarea") &&tempobj.value=='')||(tempobj.type.toString().cha rAt(0)=="s"&&tempobj.selectedIndex==-1)){

    pass=false

    break

    }

    }

    }

    }

    if (!pass){

    alert("You did not insert all the data correctly. Some information miss. Click OK and verify your data.")

    return false

    }

    else

    return true

    }

    </script>


    ....

    <FORM onSubmit="return checkrequired(this)">

    non funziona.

    dove devo mettere sto: required

    thx

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    ciao @rgo,

    il controllo viene fatto negli elementi del form di tipo text, textarea e select che hanno come inizio nome required
    codice:
    <input type="text" name="requiredText">
    
    <textarea name="requiredTextarea"></textarea>
    
    <select name="requiredCombo" multiple>
      <option value="1">uno</option>
      <option value="2">due</option>
      <option value="3">tre</option>
    </select>

  3. #3
    Utente bannato
    Registrato dal
    Sep 2000
    Messaggi
    214
    e allora xchè quando scrivo

    <input type="text" name="requiredNome">

    in realtà se non inserisco il modulo invia ugualmente senza alert?

  4. #4
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    "se non inserisco il modulo" intendevi se non scrivi nulla nel campo?
    lo script funziona, il problema dev' essere altrove,
    tipo il campo input si trova fuori dal form o cose del genere.
    Se non salta fuori l' inghippo posta un link alla pagina o direttamente il codice che usi nella pagina

  5. #5
    Utente bannato
    Registrato dal
    Sep 2000
    Messaggi
    214
    Originariamente inviato da Xinod
    "se non inserisco il modulo" intendevi se non scrivi nulla nel campo?
    lo script funziona, il problema dev' essere altrove,
    tipo il campo input si trova fuori dal form o cose del genere.
    Se non salta fuori l' inghippo posta un link alla pagina o direttamente il codice che usi nella pagina
    [i]<html>

    <head>
    <title>Order Form</title>
    <script language="JavaScript1.1">

    function checkrequired(which){

    var pass=true

    if (document.images){

    for (i=0;i<which.length;i++){

    var tempobj=which.elements

    if (tempobj.name.substring(0,8)=="required"){

    if (((tempobj.type=="text"||tempobj.type=="textarea") &&tempobj.value=='')||(tempobj.type.toString().cha rAt(0)=="s"&&tempobj.selectedIndex==-1)){

    pass=false

    break

    }

    }

    }

    }

    if (!pass){

    alert("You did not insert all the data correctly. Some information miss. Click OK and verify your data.")

    return false

    }

    else

    return true

    }

    </script>


    <style type="text/css">
    <!-- A:link {text-decoration: none;}
    A:visited {text-decoration: none;} -->
    </style>
    </HEAD>
    <BODY BGCOLOR="#333333" text="#ffffff" LINK="#ff0000" VLINK="#ff0000" ALINK="#FF0000">




    <FONT FACE="Verdana" SIZE="2"COLOR="#ff0000">Check your order!
    </FONT></p>
    <HR WIDTH="100%" SIZE="18" COLOR="#ff0000">





    <font face="Verdana" size="2">WARNING!: This cart can contain only 20 items for each order.


    Please do not change your order on this page.

    You must return to the products page clicking on "item#", and change your order there.</font></p>


    <table border="1" bordercolor="#333333" width="80%">
    <tr>
    <td width="12%"><font face="Verdana" size="2">Cod.#</font></td>
    <td width="13%"><font face="Verdana" size="2">Q.ty</font></td>
    <td width="15%"><font face="Verdana" size="2">Unit</font></td>
    <td width="15%"><font face="Verdana" size="2">Total</font></td>
    <td width="46%"><font face="Verdana" size="2">Delete</font></td>
    </tr>
    </table>







    <script language = "JavaScript">

    /* This function prints out each order. It accepts one parameter which is an instance of the
    product object defined in index.htm. It creates four text boxes to store the PRODUCT ID,
    QUANTITY BOUGHT, PRICE PER ITEM, TOTAL FOR THIS PRODUCT. It then prints a hyperlink displaying
    the products name, and leading to the products URL. This enables the customer to quickly
    locate the product if they wish to change their order in relation to this product. */

    i = 0;

    function printLine(pr)
    {

    product = parent.getCookie(pr.name);
    if (product > 0){
    prodtotal = product * pr.price;
    quantity = 'quantity' + 3;
    document.write("<INPUT TYPE='Text' SIZE='7' NAME=Product_Id", i, " VALUE=", pr.id, ">");
    document.write("<INPUT TYPE='Text' SIZE='7' NAME=Quantity", i, " VALUE=", product, ">");
    document.write("<INPUT TYPE='Text' SIZE='9' NAME=Price", i, " VALUE=", 'Eu.' + pr.price, ">");
    document.write("<INPUT TYPE='Text' SIZE='9' NAME=Total", i, " VALUE=",'Eu.' + prodtotal, ">");
    document.write(" ", pr.name, "

    ");
    calculateTotal(prodtotal);
    i++;

    tax = grandtotal / 5
    totalecontasse = grandtotal + tax

    }
    }

    /* --------------------------------------------------------------------------------------------

    Each time a product is printed out, this function is called from the printLine function with
    the total cost for that product. These are then added together in this function. When the
    printLine has been called for each product the customer has bought, this will hold the
    total price of all the products bought by that customer. */

    function calculateTotal(num)
    {
    grandtotal += num;
    return grandtotal;
    }

    /* --------------------------------------------------------------------------------------------

    In this section variables are initialised and functions are called to print out
    the entire orders list.*/
    i = 0;
    grandtotal = 0;
    tax = 0;
    totalecontasse = 0;
    document.write("<form ACTION='mailto:mionome@mioisp.it' method='POST' enctype='text/plain'>");
    /* document.write("<form action='http://localhost/cgi-bin/dbscript.pl' method='POST'>");
    document.write("<form ACTION='http://homepages.paradise.net.nz/cgi-bin/mailto' METHOD='POST'><input type='hidden' name='recipient' value='milhous@paradise.net.nz'><input type='hidden' name='followup-page'' value='http://homepages.paradise.net.nz/milhous/'>");
    */

    // ***INSERT HERE***
    printLine(parent.item1);
    printLine(parent.item2);
    printLine(parent.item3);
    printLine(parent.item4);
    printLine(parent.item5);
    printLine(parent.item6);
    printLine(parent.item7);
    printLine(parent.item8);
    printLine(parent.item9);
    printLine(parent.item10);
    printLine(parent.item11);
    printLine(parent.item12);
    printLine(parent.item13);
    printLine(parent.item14);
    printLine(parent.item15);
    printLine(parent.item16);
    printLine(parent.item17);
    printLine(parent.item18);
    printLine(parent.item19);
    printLine(parent.item20);
    printLine(parent.item21);

    document.write(" Sub Total: <INPUT TYPE='Text' SIZE='9' NAME='SUBTOTAL' VALUE=",'Eu.' + grandtotal, ">");
    /*document.write(" IVA : <INPUT TYPE='Text' SIZE='9' NAME=IVA", i, " VALUE=", 'E.' + tax, ">");*/
    /*document.write(" Totale con IVA : <INPUT TYPE='Text' SIZE='9' NAME='grandtotal' VALUE=",'E.' + (grandtotal + tax), ">");*/
    document.write("

    Shipping : &nbsp<INPUT TYPE='Text' SIZE='9' NAME='SHIPPING' VALUE=",'Eu.' + parent.postage, ">");
    document.write("

    Total : &nbsp<INPUT TYPE='Text' SIZE='9' NAME='TOTAL', i, VALUE=",'Eu.' + (parent.postage + grandtotal), ">");
    </script>




    <p align=left"><u>Currency Converter</u></p>

    <HR WIDTH="100%" SIZE="18" COLOR="#ff0000">


    <a name="ordEd">
    <FONT FACE="Verdana" SIZE="2"COLOR="#FF0000">Insert your shipping data
    </FONT></a>



    <FORM onSubmit="return checkrequired(this)">
    <table border="0" cellpadding="0" cellspacing="0" bgcolor="#333333" width="100%">
    <tr>
    <td align="center" colspan="4" bgcolor="#333333">

    <font face="Verdana" size="2" color="#ff0000">Shipping Data</font>[/b]


    </td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Firstname:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="30" maxlength="30" name="requiredFirstname"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Lastname:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="30" maxlength="30" name="requiredLastname"></td>
    </tr>

    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Email Address:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="30" maxlength="60" name="requiredEmail"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Address:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="30" maxlength="60" name="requiredAddress"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">City:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="20" maxlength="30" name="requiredCity"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Province/State:</font></td>
    <td bgcolor="#333333"><input type="text" size="20" maxlength="10" name="requiredCounty"></td>
    <td align="right" bgcolor="#333333"></td>
    <td bgcolor="#333333"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Postal/Zip code:</font></td>
    <td bgcolor="#333333"><input type="text" size="9" maxlength="10" name="requiredZipcode"></td>
    <td align="right" bgcolor="#333333"></td>
    <td bgcolor="#333333"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Country:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="25" maxlength="50" name="requiredCountry"></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Credit Card:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="25" maxlength="25" name="CC" value="disabled" disabled></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Card number:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="25" maxlength="25" name="Num." value="disabled" disabled></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Expiry Date:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="13" maxlength="13" name="Exp." value="disabled" disabled></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#333333"><font face="Verdana" size="2">Phone:</font></td>
    <td colspan="3" bgcolor="#333333"><input type="text" size="25" maxlength="25" name="Ph." value="disabled" disabled></td>
    </tr>
    <tr>
    <td align="center" colspan="4" ><font face="Verdana" size="1"><input type="checkbox" name="Mailing_list" value="yes">Check here to be included on our mailing list</font>

    </td>
    </tr>
    <tr>
    <td align="center" colspan="4" bgcolor="#333333"><font face="Verdana" size="2" color="#ff0000">Shipping/Payments details
    </font>


    </td>
    </tr>
    <TR><TD WIDTH=20% VALIGN=TOP><font face="Verdana" size="2">Shipping:</font></TD><TD WIDTH=80% VALIGN=TOP>
    <INPUT TYPE="CheckBox" NAME="requiredShipping" VALUE="By mail" CHECKED><font face="Verdana" size="1"> By Mail</font>
    </TD></TR>
    <TR><TD WIDTH=30% VALIGN=TOP><font face="Verdana" size="2">Delivery:</font></TD><TD WIDTH=70% VALIGN=TOP>
    <INPUT TYPE="CheckBox" NAME="requiredDelivery" VALUE="usually in a week after the shipping" CHECKED><font face="Verdana" size="1"> usually in a week after the shipping</font>
    </TD></TR>
    <TR><TD WIDTH=30% VALIGN=TOP><font face="Verdana" size="2">Payment:</font></TD><TD WIDTH=70% VALIGN=TOP>
    <INPUT TYPE="CheckBox" NAME="requiredPayment" VALUE="Only by Pay Pal" CHECKED><font face="Verdana" size="1"> Only by <font size="1" color=#ffffff"><u>PayPal account</u></font>

    </font>
    </TD></TR>
    <TR><TD WIDTH=30% VALIGN=TOP><font face="Verdana" size="2">Age Certification:</font></TD><TD WIDTH=70% VALIGN=TOP>
    <INPUT TYPE="CheckBox" NAME="requiredOver 18" VALUE="I'm over 18" CHECKED><font face="Verdana" size="1"> Yes, I am over 18</font></td></tr>
    <TR><TD WIDTH=30% VALIGN=TOP><font face="Verdana" size="2">Privacy:</font></TD><TD WIDTH=70% VALIGN=TOP>
    <INPUT TYPE="CheckBox" NAME="requiredPrivacy" VALUE="Authorized" CHECKED><font face="Verdana" size="1"> I authorize xxx.com tu use my personal data
    only for delivery and promotions.</font></td></tr>
    <TR><TD WIDTH=30% VALIGN=TOP>

    </TD><TD WIDTH=70% VALIGN=TOP>


    </td></tr>
    </table>
    <p align="center">
    <input type="submit" value="Order now"><input type="reset" value="Reset"></p>
    </form></p>





    <font face="Verdana" size="1" color="#ff0000">&copy Powered by [b]The Shopping Cart v1.1[b]</font></p>

    </body>
    </html>



    è solo una prova eh? non guardare il pelo...

    è parte di un carrello.


  6. #6
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    l' errore è il form che hai aggiunto a mano perchè c' è già l' apertura <form> scritta da javascript (e anche se le chiusure fossero in numero corretto non è possibile annidare form),
    se vuoi aggiungere il controllo onsubmit devi scriverlo qui
    document.write("<form onsubmit=\"return checkrequired(this)\" ACTION='mailto:mionome@mioisp.it' method='POST' enctype='text/plain'>");

    questo puoi rimuoverlo completamente
    <FORM onSubmit="return checkrequired(this)">

    ciao ciao

  7. #7
    Utente bannato
    Registrato dal
    Sep 2000
    Messaggi
    214
    grazie signore grazie!

    grazie signore grazie!

    grazie signore grazie!

    (quelli là)


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.