www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: [RESOLVED] HTML Form issues

Hybrid View

  1. #1
    Join Date
    Jun 2013
    Posts
    36

    resolved [RESOLVED] HTML Form issues

    This is all new to me and I am so frustrated - Iím working on an HTML Form, I have googled for days on this but can't seem to find anything helpful. Iím running into a couple of issues. (1) Unable to have 2 option values [one for Branch and the other for email to Branch Mgr.] Iím unable to get my output to email to branch managers AND contain the branch (see example below). Basically, I only need one of the drop downs to contain the 12 mgrs. emails. I donít want the managers to receive unnecessary emails that donít affect their business. * Ideally I need 2 option values and will probably have to create some sort of an array but not sure which direction to go with this.

    (2) Also, I have javascript code to add a row for additional equipment. When I add an additional row and fill it in the Stock #, Serial # and Description come out undefined and then basically wipe out all content of those 3 fields for previous equipment.

    Current output:
    Transfer Order

    Stock Number: 12345
    Serial Number: 67890
    Description: tractor
    Requested By: Jane
    Requested Date: 06/21/2013
    Customer Info: John
    Requesting Branch: johnd@gmail.com
    Shipping Branch: jeffp@gmail.com
    SHOULD BE:
    Requesting Branch: Boston
    Shipping Branch: Hanover

    Intent for form Ė Sales Rep fills out form fields with equipment to transfer from one place to another. He then selects (2 drop downs) Requesting Org and a Shipping Org, emails will then go to specific Org Mgr. Once Submit button is selected 4 additional people will also receive the request (this will be accomplished using a distribution list)


    Thanks for any help someone can provide.

  2. #2
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    to clarify. your problem is when the rep fills the form out you need to create the email script which grabs the selected managers email from a drop down which is selected by the rep?

    if so to make it easy would it be possible to just add the managers email to the drop down box instead of the managers name> then when you pull in the form data just call on the id of the form field to the email header and save ur self a step. if u want to do it with php just create a variable for each managers name = to their email and then in the email script instead of adding an email just type the email variable and set an array showing each managers name is = to their email address.

  3. #3
    Join Date
    Jun 2013
    Posts
    36

    My code is attached

    Quote Originally Posted by Nicholas Diaz View Post
    to clarify. your problem is when the rep fills the form out you need to create the email script which grabs the selected managers email from a drop down which is selected by the rep?

    if so to make it easy would it be possible to just add the managers email to the drop down box instead of the managers name> then when you pull in the form data just call on the id of the form field to the email header and save ur self a step. if u want to do it with php just create a variable for each managers name = to their email and then in the email script instead of adding an email just type the email variable and set an array showing each managers name is = to their email address.
    I have attached the latest code that I have been working on. The managers email is what is in the actual code and that would work but I also need the requested branch and shipping branch to show up in my out like this example:

    Stock Number: 12345
    Serial Number: 67890
    Description: equipment
    Requested By: Jane
    Requested Date: 06/20/2013
    Customer Info: John Doe
    Requesting Branch: jjones@gmail.com ** This should be Orlando
    Shipping Branch: Boston ** this should email to jdoe@gmail.com

    Code: This is just part of the code that I need to have an email go to the branch mgr and also provide me a request branch of Boston or Raleigh, etc.
    <html>
    <head>
    <title>Multiple Option Attributes</title>
    </head>
    <body>

    <form name="transferform" id = "transferform">


    <p>
    Requested Branch: <br>
    <select name="requestbranch" id="requestbranch" onchange="rem1(this)">
    <option selected value=""> Choose One</option>
    <option value="Boston"> Boston </option>
    <option value="Raleigh"> Raleigh </option>
    <option value="Orlando"> Orlando </option>
    <option value="Topeka">Topeka</option>

    </select>

    </form>

    <script type = "text/javascript">
    // Branch Array

    var branch = [];
    branch['Boston'] = ["Boston","jdoe@gmail.com"];
    branch['Raleigh'] = ["Raleigh","bsmith@gmail.com"];
    branch['Orlando'] = ["Orlando","jjones@gmail.com"]
    branch['Topeka'] = ["Topeka","lbaker@gmail.com"]

    function rem1(which) {
    if (which.value !="") {
    var ndx = document.transferform.requestbranch.selectedIndex;
    var val = which.value; // .branch
    var loc = branch[which.value][0]; // .location;
    var email = branch[which.value][1]; // .email;

    alert("Value "+ndx+": "+val+"\nRequesting Branch: "+loc+"\nEmail: "+email);
    } else { alert('Requires selection'); }
    }

    </script>

    ********************** My attempt to send to email below***************

    <!--Code above works as an alert, now I need to get it to output to email showing Requesting Branch: Boston, etc. and to email properly to Branch Manager

    <input LANGUAGE="JavaScript" TYPE="button" class="button" VALUE="Submit"
    ONCLICK="location.href = &quot;mailto:&quot; +
    document.transferForm.requestbranch.options[document.transferForm.requestbranch.selectedIndex].value + &quot;; &quot; +
    "+ndx+": "+val+"\nRequesting Branch: "+loc+"\nEmail: "+email: NAME="Send email">-->
    </body>
    </html>

  4. #4
    Join Date
    Jun 2013
    Location
    Chandigarh
    Posts
    1
    Hi dear thanks for share this information here. I really appreciate your work. I wanna get a website designing in HTML, CSS,WS3 etc.

  5. #5
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    I am sorry for asking questions and not getting to the answer but if it makes you feel better this is easy and i already have a script writted to send u i just want to alter it for you so i need to correct info.

    in your first email you say you need 12 managers in the drop down but then in this code your showing me 4 branches? is that because there is only 4 branches and there are 3 managers at each branch?

    i need all the variables. so do this.

    1. how many managers list there names and what branch they are associates with.

    2. how many branches and how many managers at each branch

    3. the person filling out the form gets to pick the shippin branch? this is kinda confusing with the details your adding.

    if you have some options that are only two options make them radio buttons instead of drop down
    if i was going to do this i would set up statements in php. such as. if someone fills out the form and all the information is them adding and they can only select a few options that have common pairs.

    for instance. if someone picks the branch in orlando and you know the manager of that branch then write a statement like this

    if $orlando then creaate the whole email statement to send the forms fields to the branch manager

    elseif $topeka copy the same statement and change the email address or what ever u need

    elseif one more of those to get all four branches

    else and then finally here is your fourth statement.

    basically im saying if you had information coming from those forms that means that if this manager is picked or that branch is picked they match always then you can just write statement using

    if elseif and else to get this done.

    if that helps and all you need is help writing the statements and email script thats a 10 minute job not a big deal at all. just let me know.

    and if im way off and not following you still dont paste code in just write me detailed description of what you need and ill send you back some code.

  6. #6
    Join Date
    Jun 2013
    Posts
    36
    Hi Nicholas,

    No problem – sorry for the confusion, for the sake of shortening my example I just showed 4 branches and changed names for security sake. I would love it if you could help me with some sort of code and give me an idea where I should place it within my code. (above header, within body, form, etc.) Also, I do have a server setup with PHP.

    1. There are 12 managers, I don’t necessarily want their names showing in the email, only the branch name.

    branch['Boston'] = ["Boston","jdoe@gmail.com"];
    branch['Raleigh'] = ["Raleigh","bsmith@gmail.com"];
    branch['Orlando'] = ["Orlando","jjones@gmail.com"]
    branch['Topeka'] = ["Topeka","lbaker@gmail.com"]
    branch['Toledo'] = ["Toledo","tbrown@gmail.com"]
    branch['Cinncinatti'] = ["Cinncinatti","pthomas@gmail.com"]
    branch['Dallas'] = ["Dallas","ktaylor@gmail.com"]
    branch['Columbia'] = ["Columbia","ksmith@gmail.com"]
    branch['Buffalo'] = ["Buffalo","lstone@gmail.com"]
    branch['Kansas City'] = ["Kansas City","jdepp@gmail.com"]
    branch['Fairfax'] = ["Fairfax","hbrooks@gmail.com"]
    branch['Los Angeles'] = ["Los Angeles","jshelton@gmail.com"]




    2. There are 12 branches and 1 manager per branch (total 12 branch managers).

    3. The person filling out the form will select a requesting branch and a shipping branch (mgrs at those 2 branches should receive email). I also have to send the email to a DL of 4 people every time so that would be like a cc: selectmgrs@gmail.com. But I think I can figure that out.

    4. One other thing is I have an Add Row function. When I select it to add an additional piece of equipment then my stock number, serial number and description return undefined value. (I believe that is because I have to create a function that adds a row to return those values +1 if there is additional equipment.) Does that sound right?

    Thanks for your help,
    SparkyMom7

  7. #7
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ok let me make sure i have this 100% straight.

    12 managers run 12 branches. if someone wants a product they select the branch they are at and they select the branch they want the product to come from??????
    then no matter what happens there are four other people who get emailed no matter whats picked. Every time the form submit these four people get the email.

    So in a email submission there will be a total of 6 people emailed every time? 4 people then the two that run the two branches? and what do you mean a DL of four people? what do you mean by DL?

  8. #8
    Join Date
    Jun 2013
    Posts
    36

    response to questions

    Quote Originally Posted by Nicholas Diaz View Post
    ok let me make sure i have this 100% straight.

    12 managers run 12 branches. if someone wants a product they select the branch they are at and they select the branch they want the product to come from?????? Correct
    then no matter what happens there are four other people who get emailed no matter whats picked. Every time the form submit these four people get the email. Correct

    So in a email submission there will be a total of 6 people emailed every time? 4 people then the two that run the two branches? and what do you mean a DL of four people? what do you mean by DL?
    dl = distribution list of 4 people

    Thanks

    looking at code

  9. #9
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ok were gonna have to make the cities and emails an array can you send me the email address for each city

  10. #10
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    wait i think i figured it out!!!!!!!! ok we change the value of each city to the correct email address. and then in the send.php file we give each city the posted email and assign the r_email and the s_email to every string in each drop down!!!!!!!! send me the emails i think i can have it working in a minutes

  11. #11
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ok im not going to add css and format this stuff but ill help you with the code. here is my plan. look over this form and tell me if this is correct.

    If it is what im going to do is in the script ill make it so that if someone selects boston for requested branch and orlando for sending then those
    cities will variables of the correct email address. then ill write the script to email. and no matter what the people select it will get emailed to the
    correct manager and then ill add the extra 4 people to the email no matter what.

    look over this form and tell me if I have everything. Also copy and paste the cities in to ABC order so it looks more professional.

    question, the first 6 fields will they just be data that the user types in? or do you need them to be drop down boxes of products and serial numbers?

    the way its set up now they just type the info in the first 6 fields then select the branch for requesting and then sending. then there is a place
    for them to add a message or notes that will be sent in the email.

    if this is all correct ill just need the four email address for the people that get emailed everytime and i can knock this out for you. so try to get back to me quick.

    Code:
     				<form method="POST" action="send.php"> 
    
    Stock Number: 	<input name="stockNumber" type="text"><br>
    Serial Number: 	<input name="serialNumber" type="text"><br>
    Description: 	<input name="description" type="text"><br>
    Requested By:	<input name="requestedBy" type="text"><br>
    Requested Date:	<input name="RequestedDate" type="text"><br>
    Customer Name:	<input name="customerName" type="text"><br>
    
    
    
    Requesting Branch:
    <select class="select" name="R_branch" id="R_branch">
    <option value="">Requesting Branch
    <option value="R_boston">Boston
    <option value="R_columbia">Columbia
    <option value="R_Raleigh">Raleigh
    <option value="R_Orlando">Orlando
    <option value="R_Topeka">Topeka
    <option value="R_Toledo">Toledo
    <option value="R_Cinncinatti">Cinncinatti
    <option value="R_Dallas">Dallas
    <option value="R_Buffalo">Buffalo
    <option value="R_Kansas City">Kansas City
    <option value="R_Fairfax">Fairfax
    <option value="R_Los Angelas">Los Angelas
    
    Sending Branch:
    <select class="select" name="S_branch" id="S_branch">
    <option value="">Sending Branch
    <option value="S_boston">Boston
    <option value="S_columbia">Columbia
    <option value="S_Raleigh">Raleigh
    <option value="S_Orlando">Orlando
    <option value="S_Topeka">Topeka
    <option value="S_Toledo">Toledo
    <option value="S_Cinncinatti">Cinncinatti
    <option value="S_Dallas">Dallas
    <option value="S_Buffalo">Buffalo
    <option value="S_Kansas City">Kansas City
    <option value="S_Fairfax">Fairfax
    <option value="S_Los Angelas">Los Angelas
    
    
    
    
    Message:<br> 
     <textarea name="message" rows="15" cols="40"></textarea><br> 
     <input type="submit"> 
     </form>

  12. #12
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ok so here is the revision of the form and the script to send the email to the two people requesting branch and sending branch. all we have to do is turn the two branch option values in to strings that = $R_email and $S_email and then it should work. also i need someone to look at my script where im calling $S_email in the $to field and tell me if that's written correct or if i need to add single quotes around $S_email?

    and someone help us turn the two values to the string we need.

    form
    Code:
      				<form method="POST" action="send.php"> 
    
    Stock Number: 	<input name="stockNumber" type="text"><br>
    Serial Number: 	<input name="serialNumber" type="text"><br>
    Description: 	<input name="description" type="text"><br>
    Requested By:	<input name="requestedBy" type="text"><br>
    Requested Date:	<input name="requestedDate" type="text"><br>
    Customer Name:	<input name="customerName" type="text"><br>
    
    
    
    Requesting Branch:
    <select class="select" name="R_branch" id="R_branch">
    <option value="">Requesting Branch
    <option value="R_boston">Boston
    <option value="R_columbia">Columbia
    <option value="R_raleigh">Raleigh
    <option value="R_orlando">Orlando
    <option value="R_topeka">Topeka
    <option value="R_toledo">Toledo
    <option value="R_cinncinatti">Cinncinatti
    <option value="R_dallas">Dallas
    <option value="R_buffalo">Buffalo
    <option value="R_kansas">Kansas City
    <option value="R_Fairfax">Fairfax
    <option value="R_la">Los Angelas
    
    Sending Branch:
    <select class="select" name="S_branch" id="S_branch">
    <option value="">Sending Branch
    <option value="S_boston">Boston
    <option value="S_columbia">Columbia
    <option value="S_raleigh">Raleigh
    <option value="S_orlando">Orlando
    <option value="S_topeka">Topeka
    <option value="S_toledo">Toledo
    <option value="S_cinncinatti">Cinncinatti
    <option value="S_dallas">Dallas
    <option value="S_buffalo">Buffalo
    <option value="S_kansas City">Kansas City
    <option value="S_fairfax">Fairfax
    <option value="S_la">Los Angelas
    
    
    
    
    Message:<br> 
     <textarea name="message" rows="15" cols="40"></textarea><br> 
     <input type="submit"> 
     </form>
    php email script
    Code:
     <?php 
    sleep(2);
    //Sanitize incoming data and store in variable
    
    $stockNumber =  trim(stripslashes(htmlspecialchars ($_POST['stockNumber'])));		
    $serialNumber =  trim(stripslashes(htmlspecialchars ($_POST['serialNumber'])));	
    $description =  trim(stripslashes(htmlspecialchars ($_POST['description'])));	
    $from = trim(stripslashes(htmlspecialchars ($_POST['requestedBy'])));	
    $requestedDate =  trim(stripslashes(htmlspecialchars ($_POST['requestedDate'])));	
    $customerName =  trim(stripslashes(htmlspecialchars ($_POST['customerName'])));	
    $message =  trim(stripslashes(htmlspecialchars ($_POST['message'])));	
    
    $R_boston =  trim(stripslashes(htmlspecialchars ($_POST['R_boston'])));	
    $R_columbia =  trim(stripslashes(htmlspecialchars ($_POST['R_columbia'])));	
    $R_raleigh =  trim(stripslashes(htmlspecialchars ($_POST['R_raleigh'])));	
    $R_orlando =  trim(stripslashes(htmlspecialchars ($_POST['R_orlando'])));	
    $R_topeka =  trim(stripslashes(htmlspecialchars ($_POST['R_topeka'])));	
    $R_toledo =  trim(stripslashes(htmlspecialchars ($_POST['R_toledo'])));	
    $R_cinncinatti =  trim(stripslashes(htmlspecialchars ($_POST['R_cinncinatti'])));	
    $R_dallas =  trim(stripslashes(htmlspecialchars ($_POST['R_dallas'])));	
    $R_buffalo =  trim(stripslashes(htmlspecialchars ($_POST['R_buffalo'])));	
    $R_kansas =  trim(stripslashes(htmlspecialchars ($_POST['R_kansas'])));	
    $R_fairfax =  trim(stripslashes(htmlspecialchars ($_POST['R_fairfax'])));	
    $R_la =  trim(stripslashes(htmlspecialchars ($_POST['R_la'])));	
    
    $S_boston =  trim(stripslashes(htmlspecialchars ($_POST['S_boston'])));	
    $S_columbia =  trim(stripslashes(htmlspecialchars ($_POST['S_columbia'])));	
    $S_raleigh =  trim(stripslashes(htmlspecialchars ($_POST['S_raleigh'])));	
    $S_orlando =  trim(stripslashes(htmlspecialchars ($_POST['S_orlando'])));	
    $S_topeka =  trim(stripslashes(htmlspecialchars ($_POST['S_topeka'])));	
    $S_toledo =  trim(stripslashes(htmlspecialchars ($_POST['S_toledo'])));	
    $S_conncinatti =  trim(stripslashes(htmlspecialchars ($_POST['S_cinncinatti'])));	
    $S_dallas =  trim(stripslashes(htmlspecialchars ($_POST['S_dallas'])));	
    $S_buffalo =  trim(stripslashes(htmlspecialchars ($_POST['S_buffalo'])));	
    $S_kansas =  trim(stripslashes(htmlspecialchars ($_POST['S_kansas'])));	
    $S_fairfax =  trim(stripslashes(htmlspecialchars ($_POST['S_fairfax'])));	
    $S_la =  trim(stripslashes(htmlspecialchars ($_POST['S_la'])));	
    
    
    
    //Prepare information from form to be sent
    $to = $S_email;
    $from = 'admin@test.com';
    $headers = 'MIME-VERSION: 1.0' . '\n';
    $headers .= 'From: $from' . '\n';
    $subject = 'Online Order Request';
    $body = 'Stock Number: ' .$stockNumber . PHP_EOL;
    $body .= 'Serial Number: ' .$serialNumber . PHP_EOL;
    $body .= 'Description: ' .$description . PHP_EOL;
    $body .= 'Requested Date: ' .$requestedDate . PHP_EOL;
    $body .= 'Customer Name: ' .$customerName . PHP_EOL;
    $body .= 'Message: ' .$message . PHP_EOL;
    
    // Form data was successfull so we will now send admin email and return message to the user
    $success = (mail($to, $subject, $body, $headers, '-f admin@test.com.com')); 
    	echo 'Thank you, your request has been sent!';				  
    	
    	if ($success) (mail($R_email, $subject, $body, $headers, '-f admin@test.com.com'));	
    	
    	else 
    	echo 'Woops! Something went wrong please contact us directly';
    		
    
    ?>
    Last edited by Nicholas Diaz; 06-21-2013 at 06:45 PM.

  13. #13
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ya we need to change the variables of the states to $email@email.com and then convert them all to the same thing like $S_email and then do the same for R and then we can just add for my static email lines at the bottom. no problem at all. all were lacking is the string. were real close. this is a fun one by the way. I love when questions get asked that teach me something.

  14. #14
    Join Date
    Jun 2013
    Posts
    36

    Another question

    Quote Originally Posted by Nicholas Diaz View Post
    ya we need to change the variables of the states to $email@email.com and then convert them all to the same thing like $S_email and then do the same for R and then we can just add for my static email lines at the bottom. no problem at all. all were lacking is the string. were real close. this is a fun one by the way. I love when questions get asked that teach me something.
    I have the CSS all done, the first 6 fields have been completed, Requested Date is actually setup as a Date Picker. I also do have all of my branches in alphabetical order, my form is actual very nice looking I just have been struggling with getting output to email to individual branches.

    Clarification - not sure I understand, when you say change the variables of the states to $email@email.com is that in the php code - like so?

    $R_email@email.com = trim(stripslashes(htmlspecialchars ($_POST['R_boston'])));

    $S_email@email.com = trim(stripslashes(htmlspecialchars ($_POST['S_boston'])));


    As for the 4 additional people that will receive the email, the email would be something like group@email.com (it includes all 4 managers).

    I appreciate your help more than you will ever know.

  15. #15
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    that didnt work... im were gonna need some help on this one. where is NogDog when you need him... Were gonna have to use an array and I cant figure out how to pass a variable in with the $to variable in the email function. the form works when u put a email address in. i just cant get it to pass the 2 most important fields. I will keep working on it over the weekend. i have a meeting tomorrow with a friend who will be able to do it. if you get the answer before me please post it cause i need to learn more about arrays anyways.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles