form problem

Hi there, I’m having difficulty with a form.

My html should display a bunch of drop down number menu options followed by ‘other’ which when selected will open a space for text input. Currently preselected numbers do not get sent only typed text does:

html:
product name and number [1,2,3…1000,other]

source:

[code]

  • 23 xyz-001 brand Salt 12/1.36 bx  
    011000 other
  • [/code]

    There is a huge list of such lines but it the form seems to work fine for the text fields just not the selected numerics.

    Any help is appreciated.

    Is that the entire code?

    I get the Product name and the drop down of numbers like you said…

    When I select stuff in the drop down nothing happens…

    What do you want to happen?

    Thanks for your speedy response!

    This is just a part of the code, the rest is filler.

    Essentially after selecting the numbers (or typing it in manually by selecting ‘other’), there is a submit button which calls another script to email the line that was selected with the corresponding number.

    Currently it works fine if the later method (select ‘other’ which toggles on a blank box in which we type the amount, say, ‘5’. The email gets sent to me stating: Blah blah blah…5

    But when the former method selecting the number from the dropdown is used, the enail states only: blah blah blah…

    But 5 does not appear.

    Thanks in advance.

    I don’t have my code with me so I won’t be able to post it til tomorrow.

    Ok post it tomorrow and I’ll try to take a look at it.

    Thanks again!

    I have trimmed out some of the obvious fat, but the code is still quite long:

    [php]<?php
    //phpinfo();
    //Start session
    session_start();
    //unset($_SESSION[‘SESS_MEMBER_ID’]);
    //Check whether the session variable SESS_MEMBER_ID is present or not
    //echo $_SESSION[‘SESS_MEMBER_ID’];
    if(!isset($_SESSION[‘SESS_MEMBER_ID’]) || (trim($_SESSION[‘SESS_MEMBER_ID’]) == ‘’)) {
    header(“location: …/Login.html”);
    exit();
    }
    ?>[/php]

    [code]

    Order Sheet body{ margin-left: 18px; margin-top: 18px; } body{ font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color : #474747; background-color: transparent; margin-top: 20px; } select, option{ font-size:13px; } ol.phpfmg_form{ list-style-type:none; padding:0px; margin:0px; } ol.phpfmg_form li{ margin-bottom:5px; clear:both; display:block; overflow:hidden; width: 100% } .form_field, .form_required{ font-weight : bold; } .form_required{ color:red; margin-right:8px; } .field_block_over{ } .form_submit_block{ padding-top: 3px; } .text_box, .text_area, .text_select { width:60px; } .text_area{ height:80px; } .form_error_title{ font-weight: bold; color: red; } .form_error{ background-color: #F4F6E5; border: 1px dashed #ff0000; padding: 10px; margin-bottom: 10px; } .form_error_highlight{ background-color: #F4F6E5; border-bottom: 1px dashed #ff0000; } div.instruction_error{ color: red; font-weight:bold; } hr.sectionbreak{ height:1px; color: #ccc; } #one_entry_msg{ background-color: #F4F6E5; border: 1px dashed #ff0000; padding: 10px; margin-bottom: 10px; } div.col_label{ float:left; width:100%; text-align: left; } div.col_field{ margin-left:15px; width:-50px; float:right; } li { background: silver; } li:nth-child(odd) { background: white; }
    <script type="text/javascript" src="../js/siteUtil.js"></script>
    <script type="text/javascript">
    

    sfHover = function() {
    var el = document.getElementById(‘Nav1’);
    if(!/\bnav\b/.test(el.className) && el.tagName == ‘UL’)
    setHover(el);
    var ieNavs = document.getElementsByTagName(‘ul’);
    for(i=0; i<ieNavs.length; i++) {
    var ul = ieNavs[i]; if(/\bnav\b/.test(ul.className))
    setHover(ul); }}
    function setHover(nav) {
    var ieULs = nav.getElementsByTagName(‘ul’);
    if (navigator.appVersion.substr(22,3)!=‘5.0’) {
    for (j=0; j<ieULs.length; j++) {
    var ieMat=document.createElement(‘iframe’);
    if(document.location.protocol == ‘https:’)
    ieMat.src=’’;
    else if(window.opera != ‘undefined’)
    ieMat.src=’’;
    else
    ieMat.src=‘javascript:false’;
    ieMat.scrolling=‘no’;
    ieMat.frameBorder=‘0’;
    ieMat.style.width=ieULs[j].offsetWidth+‘px’;
    ieMat.style.height=ieULs[j].offsetHeight+‘px’;
    ieMat.style.zIndex=’-1’;
    ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
    ieULs[j].style.zIndex=‘101’;
    }
    var ieLIs = nav.getElementsByTagName(‘li’);
    for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
    ieLIs[i].onmouseover=function() {
    if(!/\bsfhover\b/.test(this.className))
    this.className+=’ sfhover’;
    }
    ieLIs[i].onmouseout=function() {
    if(!this.contains(event.toElement))
    this.className=this.className.replace(’ sfhover’, ‘’);
    }
    ieLIs[i].onmouseclick=function() {
    if(!this.contains(event.toElement))
    this.className=this.className.replace(’ sfhover’, ‘’);
    }}}}

    if(window.attachEvent) window.attachEvent(‘onload’, sfHover);

    <link rel="stylesheet" type="text/css" id="layout1.css" href="../css/layout1.css">
    <link rel="stylesheet" type="text/css" id="theme.css" href="../css/theme.css">
    <link rel="stylesheet" type="text/css" id="color_1.css" href="../css/color_1.css">
    <link rel="stylesheet" type="text/css" id="custom.css" href="../css/custom.css">
    
    .wrc_whole_window{ display: none; position: fixed; z-index: 2147483647; background-color: rgba(40, 40, 40, 0.9); word-spacing: normal; margin: 0px; padding: 0px; border: 0px; left: 0px; top: 0px; width: 100%; height: 100%; line-height: normal; letter-spacing: normal;}.wrc_middle_main { font-family: Segoe UI, Arial Unicode MS, Arial, Sans-Serif; font-size: 14px; width: 600px; height: auto; margin: 0px auto; margin-top: 15%; background: url(chrome-extension://icmlaeflemplmjndnaapfdbbnpncnbda/skin/images/background-body.jpg) repeat-x left top; background-color: rgb(39, 53, 62);}.wrc_middle_logo { background: url(chrome-extension://icmlaeflemplmjndnaapfdbbnpncnbda/skin/images/logo.jpg) no-repeat left bottom; width: 140px; height: 42px; color: orange; display: table-cell; text-align: right; vertical-align: middle;}.wrc_icon_warning { margin: 20px 10px 20px 15px; float: left; background-color: transparent;}.wrc_middle_title { color: #b6bec7; height: auto; margin: 0px auto; font-size: 2.2em; white-space: nowrap; text-align: center;}.wrc_middle_hline { height: 2px; width: 100%; display: block;}.wrc_middle_description { text-align: center; margin: 15px; font-size: 1.4em; padding: 20px; height: auto; color: white; min-height: 3.5em;}.wrc_middle_actions_main_div { margin-bottom: 15px; text-align: center;}.wrc_middle_actions_blue_button { -moz-appearance: none; border-radius: 7px; -moz-border-radius: 7px/7px; border-radius: 7px/7px; background-color: rgb(0, 173, 223) !important; display: inline-block; width: auto; cursor: Pointer; border: 2px solid #00dddd;}.wrc_middle_actions_blue_button:hover { background-color: rgb(0, 159, 212) !important;}.wrc_middle_actions_blue_button:active { background-color: rgb(0, 146, 200) !important; border: 2px solid #00aaaa;}.wrc_middle_actions_blue_button div { display: inline-block; width: auto; cursor: Pointer; margin: 3px 10px 3px 10px; color: white; font-size: 1.2em; font-weight: bold;}.wrc_middle_action_low { font-size: 0.9em; white-space: nowrap; cursor: Pointer; color: grey !important; margin: 10px 10px 0px 10px; text-decoration: none;}.wrc_middle_action_low:hover { color: #aa4400 !important;}.wrc_middle_actions_rest_div { padding-top: 5px; white-space: nowrap; text-align: center;}.wrc_middle_action { white-space: nowrap; cursor: Pointer; color: red !important; font-size: 1.2em; margin: 10px 10px 0px 10px; text-decoration: none;}.wrc_middle_action:hover { color: #aa4400 !important;}body,td,th { font-size: 11px; } .headingsmaltext { font-size: 11px; } #page_946f409e-e5c4-481a-ab97-8c570c6ed865 .sf_outer_wrapper .sf_wrapper .sf_main_wrapper .sf_main .sf_region6 .sf_content div #content1 div { font-size: 18px; }
    </div>
    <div class="sf_extra1"><span></span></div>
    <div class="sf_wrapper"><div style="display:block;overflow:visible;margin:0;padding:0;"><div class="sf_undocked" style="display:block;height:0;position:absolute;margin:0;padding:0;overflow:visible;width:0;top:0;z-index:999998;left:auto;">
    
    	<div class="sf_region2">
    		<div class="sf_navigation"><div class="widget main_nav"><h3 class="widget_header"><span>Main Navigation</span></h3><div class="widget_content"><div style="display:block;">
    
      [/code]

      [submenu code removed, dropdown navigator for site]
      [Had to split code as it is too long for one post, the rest to follow…]

    [code]

    Site Name

    ORDER

    	</div>
    	<div class="sf_extra6"><span></span></div>
    	<div class="sf_extra11"><span></span></div>
    	<div class="sf_main_wrapper">
    		<div class="sf_main">
    			<div class="sf_region6">
    				<div class="sf_content"><div style="display:block;zoom:1"><div id="content1"><div style="display:block;"><div style="display:block;">
    
    1. 112-24 CCC-241 Coke Coke Classic Cans 24/355ml cs  
      01234567891020501005001000 other
    2. 112-24 DCC-242 Coke Diet Coke Cans 24/355ml cs  
      01234567891020501005001000 other
    3. [/code]

      [a whole list ofother products removed]

      [code]

    4. 389 xyz-001 brand Salt 12/1.36 bx  
      0123456789102050100500 1000 other
    5. Comments
       
    [/code]

    [php]<?php
    function phpfmg_form_css(){
    phpfmg_javascript($sErr);

    end of form

    }
    ?>
    [/php]

    [code]

    	</div>
    	<div class="sf_region8">
    		
    	</div>
    	<!-- 7 -->
    	<div class="sf_region9" align="center">
    		<div class="sf_footer"><div style="display:block;"><div style="text-align: center;">&nbsp;
    		  <div align="center">Content copyright 
    		    <script type="text/javascript">if (typeof(getCopyrightDate)=='function') document.write(getCopyrightDate(2012, null, '-')); else document.write((new Date()).getFullYear());</script>
    		    . SITE.COM. All rights reserved.
    		    <script type="text/javascript" src="../js/InsertWidget.js"></script>
    		    <script type="text/javascript" language="javascript">if (WIDGETBOX) WIDGETBOX.renderWidget("140543b6-862b-4218-8d8a-adbba031261e", true);</script>
    		  </div>
    	    <div id="widgetbox_widget_parent_0" style="line-height:0"><div id="widgetbox_widget_div_0"></div></div></div></div></div>
    	</div>
    </div>
    <!-- /sf_wrapper -->
    
    [/code]

    Need to see the code in the FormToEmail.php, that’s what’s actually sending the email and should pull in the #5

    Yes I should have realized…

    [php]<?php

    error_reporting(E_ALL ^ E_NOTICE);

    /*


    The script will handle the “POST” or “GET” methods. It will also handle multiple select inputs and multiple check box inputs. If using these, you must name the field as an array using square brackets, like so: .

    ** PLEASE NOTE ** If you are using the script to process your own forms (or older FormToEmail forms) you must ensure that the email field is named correctly in your form, like this for example: . Note the lower case “email”. If you don’t do this, the visitor’s email address will not be available to the script and the script won’t be able to check the validity of the email, amongst other things. If you are using the form code below, you don’t need to check for this.

    SETUP INSTRUCTIONS
    */

    $my_email = "[email protected]";
    $from_email = “Web Order”;
    $continue = “…/Products.html”;

    $errors = array();

    // Remove $_COOKIE elements from $_REQUEST.

    if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}

    // Validate email field.

    if(isset($_REQUEST[‘email’]) && !empty($_REQUEST[‘email’]))
    {

    $_REQUEST[‘email’] = trim($_REQUEST[‘email’]);

    if(substr_count($_REQUEST[‘email’],"@") != 1 || stristr($_REQUEST[‘email’]," “) || stristr($_REQUEST[‘email’],”\") || stristr($_REQUEST[‘email’],":")){$errors[] = “Email address is invalid”;}else{$exploded_email = explode("@",$_REQUEST[‘email’]);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = “Email address is invalid”;}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = “Email address is invalid”;}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = “Email address is invalid”;}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match(’/^[a-z0-9-]+$/i’,$value)){$errors[] = “Email address is invalid”; break;}}}}}}

    }

    // Check referrer is from same site.

    if(!(isset($_SERVER[‘HTTP_REFERER’]) && !empty($_SERVER[‘HTTP_REFERER’]) && stristr($_SERVER[‘HTTP_REFERER’],$_SERVER[‘HTTP_HOST’]))){$errors[] = “You must enable referrer logging to use the form”;}

    // Check for a blank form.

    function recursive_array_check_blank($element_value)
    {

    global $set;

    if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
    else
    {

    foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}

    }

    }

    recursive_array_check_blank($_REQUEST);

    if(!$set){$errors[] = “You cannot send a blank form”;}

    unset($set);

    // Display any errors and exit if errors exist.

    if(count($errors)){foreach($errors as $value){print “$value
    ”;} exit;}

    if(!defined(“PHP_EOL”)){define(“PHP_EOL”, strtoupper(substr(PHP_OS,0,3) == “WIN”) ? “\r\n” : “\n”);}

    // Build message.

    function build_message($request_input){
    if(!isset($message_output)){$message_output ="";}
    if(!is_array($request_input)){$message_output = $request_input;}
    else{foreach($request_input as $key => $value)
    {if(!empty($value))
    {if(!is_numeric($key))
    {$message_output .= str_replace("_"," “,ucfirst($key)).”: “.build_message($value).PHP_EOL.PHP_EOL;}
    else{$message_output .= build_message($value).”, “;}}}}
    return rtrim($message_output,”, ");}

    $message = build_message($_REQUEST);

    $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL.“Thank you.”;

    $message = stripslashes($message);

    $subject = “Order Pending Confirmation”;

    $subject = stripslashes($subject);

    if($from_email)
    {

    $headers = "From: " . $from_email;
    $headers .= PHP_EOL;
    $headers .= "Reply-To: " . $_REQUEST[‘email’];

    }
    else
    {

    $from_name = “”;

    if(isset($_REQUEST[‘name’]) && !empty($_REQUEST[‘name’])){$from_name = stripslashes($_REQUEST[‘name’]);}

    $headers = “From: {$from_name} <{$_REQUEST[‘email’]}>”;

    }

    mail($my_email,$subject,$message,$headers);

    ?>

    Order Placed





    Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?>
    Your order has been placed.
    You will receive a confirmation shortly.

    Click here to continue

    [/php]

    I’m running your code and it works fine like you want it to…

    I get the product + the amount (I type in when other is selected)

    Try it yourself.

    http://www.phphelp.com/forum/membershelp/mftest1.html

    Just tried it out, and the other field works as does the comment field.

    But if I select a numeric, say ‘4’ from the drop down in the first row, and/or ‘1’ in the second, they do not show up.

    I really appreciate your investing your time on helping with this!

    I give up, this one is above my pay grade. I get dizzy even looking at that code.

    Problem solved!

    I got some help in stack overflow and it was actually a very easy mistake:

    I had duplicated variable names so they were just rewritten with nulls.

    Thanks for looking.

    Sponsor our Newsletter | Privacy Policy | Terms of Service