1

I am creating a order form for a meat locker company that sends the form to their email. There is a lot of where if you select one item you can not select another item; such as t-bone and New York Strip, you can have one or the other, but not both. Here is what my code looks like.

<P>T-bone steak <input type="radio" name="T-bone and NY" id="T-bone steak" />
or New York Strip steak <input type="radio" name="T-bone and NY" id="New York Strip" /> </p>

This does prevent a person from selecting both, but when he views in in his email he sees name="T-bone and NY" so he doesn't know which one they selected. I thought it would display the id="T-bone" or "NY Strip". I'm sure there is a better way of doing this with an if statement.

Second, when they receive the email it has all of the names of the fields people selected and it says on afterwords. For example if someone selected Prime rib the email would say:

Prime Rib: on

Is there a way to send the form exactly as the user sees it. Maybe in an image, word doc, or access data base?? I'm open to anything.

If your want to see it the url is www.spillvillelocker.com/beef.php

Thank you very much:)

1
  • 1
    I love this question for some reason... Steak and programming.. Two staples in my life. Commented Jul 7, 2010 at 17:03

4 Answers 4

1

Your code should look like this:

<P>
T-bone steak <input type="radio" name="steak" value="T-bone steak" id="tbonesteak" />
or New York Strip steak <input type="radio" name="steak" value="New York Strip" id="nystrip" /> 
</p>

Notice, I have "name" be the same for both, with different "values". Also, "id" attributes shouldn't contain spaces, so I changed them to something alphanumeric only.

Sign up to request clarification or add additional context in comments.

Comments

0

I think you just need to provide a VALUE="" attribute to show which value each radio button specifies... also NAME and ID should be equal.

<P>T-bone steak <input type="radio" name="MEAT1" id="MEAT1" value="TBONE"/> 
or New York Strip steak <input type="radio" name="MEAT1" id="MEAT1" value="NYSTRIP"/>     </p> 

2 Comments

There's no need for them to be set equally. The ID attr does not even have to be present.
You're right, I guess I do it to avoid confusion... With radio boxes specifically, I could see having them different so you could perform actions on individual options.
0

You need to set value attributes of those inputs. BTW you should not have spaces in name attributes.

Comments

0

In addition to what Mike posted, regarding your second question "why the email says 'Prime Rib: on', it is again because there is no value attribute assigned to the element. The default values for radio buttons are 'on' and 'off'. Without setting an explicit value, you're left with the defaults.

There are two things that you can do for this.

  1. Set an explicit value for the form element, something like

    <input type="radio" name="primeRib" value="Yes"> Prime Rib

That will show up as 'primeRib: Yes' in the email.

  1. The second thing you can do is use PHP to parse your responses to only send the data you want. Something along the lines of:

<?php foreach ($_POST as $key=>$value) { if ($value=="off") { continue; } else { $email.="$key\n"; } } ?>

Something like that would skip over each $_POST variable that is set to "off" and for each variable that isn't, it would add the $key (the data inside the "name" attribute) to the $email variable, or however you add the data to the email to be sent out. There's a number of things that you can do, but at least this would allow you to filter only for variables that are on/checked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.