www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 09-23-2005, 01:41 AM
    Ron Wolpa Ron Wolpa is offline
    Registered User
     
    Join Date: Oct 2003
    Location: Somewhere over the rainbow
    Posts: 23
    Lightbulb need some help ....how to validate this form........

    not entirely a javascript question as some PHP is envolved as well but ...:

    The pasted bellow code is a simple order form which I intend to validate ;
    There will be lots of checkbox (script would have to be lithe to comply with a variable number of checkbox );
    , 8 x input texts (one of which an email field to be validated on email format ) and 1 x select name ;


    Perhaps a javascript would be a simpler solution , but Iīve encountered the following difficulty :
    - name of the checkbox inputs are the same for all : name="check[]" - it makes impossible to identify every checkbox
    on javascript ;
    - I think itīs got to be changed including the way these lines are written :

    foreach( (array)$_POST['check'] as $value){
    check_msg .= "Checked: $value\n";

    Any help would be welcome
    Cheers

    Quote:
    ................ Order Form ......................................................... :

    <form name="form1" method="post" action="formpedido1.php">
    <br>
    <input type="text" name="hpxxxxxxabc" size="2" maxlength="2">
    <br>

    <input type="checkbox" name="check[]" value="hpxxxxxxabc_clicado">
    <br>
    <input type="text" name="eps00001a" size="2" maxlength="2">
    <br>
    <input type="checkbox" name="check[]" value="eps00001a_clicado">

    <br>
    <input type="text" name="nome" maxlength="50" size="45" style class="formbg">
    <br>
    <input type="text" name="endereco" maxlength="50" size="40" style class="formbg">
    <br>
    <input name="numero" type="text" class="formbg" id="numero" style size="6" maxlength="6">
    <br>
    <input name="cidade" type="text" class="formbg" id="cidade" style size="35" maxlength="35">
    <br>
    <select name="estado" size="1" style class="formbg">
    <option value="value">( Selecione )</option>
    <option selected>A</option>
    <option>B</option>
    <option>C</option>
    <option>etc</option>
    </select>
    <br>
    <input name="cep" type="text" id="cep" size="8" maxlength="8">
    <br>
    <input type="text" name="codigo_area" size="15" maxlength="5" style class="formbg">
    <br>
    <input type="text" name="telefone" size="15" maxlength="15" style class="formbg">
    <br>
    <input type="text" name="email" size="35" maxlength="100" style class="formbg">
    <br>
    <textarea name="comentarios" cols="70" rows="5"> </textarea>
    <br>

    <input type="submit" name="Submit" value="Confirmar pedido" style="background-color: #ffcc00" >
    <br>

    <input type="reset" name="Submit2" value="Limpar" style="background-color: #ffcc00">




    ...................................................... FILE formpedido1.php ............................................................................. :


    <?php
    if(isset($_POST['Submit'])) {

    $to = "john_doe@nowhere.helpme";
    $subject = "formulario_de_pedido_01";
    $nome = $_POST['nome'];
    $endereco = $_POST['endereco'];
    $numero = $_POST['numero'];
    $cidade = $_POST['cidade'];
    $estado = $_POST['estado'];
    $cep = $_POST['cep'];
    $codigo_area = $_POST['codigo_area'];
    $telefone = $_POST['telefone'];
    $email = $_POST['email'];
    $comentarios = $_POST['comentarios'];
    $hpxxxxxxabc = $_POST['hpxxxxxxabc'];
    $eps00001a = $_POST['eps00001a'];


    // ................. how to change the lines bellow ???
    foreach( (array)$_POST['check'] as $value){
    $check_msg .= "Checked: $value\n";
    }

    // _________ _________ ___________ _____________ _______ _____

    $body = "Nome: $nome\n
    Endereco: $endereco\n
    Numero : $numero\n
    Cidade : $cidade\n
    Estado: $estado\n
    Cep: $cep\n
    Cod. Area: $codigo_area\n
    Fone: $telefone\n
    Email: $email\n
    Comentarios: $comentarios\n
    Items pedidos: \n
    $check_msg\n
    Quantidade de hpxxxxxxabc : $hpxxxxxxabc\n
    Quantidade de eps00001a : $eps00001a\n
    ";



    // ________ ____________ _________________ _______ __________

    header("Location: order_confirmation.htm");
    mail($to, $subject, $body);

    } else {
    echo "error_invalid_function";
    }
    ?>
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:03 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.