0

I have a simple drop down menu on a form:

<form id="form1" name="form1" method="post" action="">
  <select name="ddlSelect" id="ddlSelect">
  <option value="">Select</option>
    <option value="-1">Yes</option>
    <option value="0">No</option>
  </select>
</form>

I would like to convert the values for each option to display in an email using a java script function but am not sure how to do this. Can anyone help? Ex. -1 = Yes, 0 = No

3
  • Since JavaScript can't send email, what language are you going to use to process the form and send email? Commented Sep 21, 2012 at 3:01
  • Is this form in the email? or is the contents of the form submitted somewhere as an email? Commented Sep 21, 2012 at 3:02
  • What do you mean by "convert"? Change the string "-1" to the number -1 (as per the two answers so far)? If so, what does that have to do with emailing? Commented Sep 21, 2012 at 3:20

2 Answers 2

1

You can convert a string to a number in javascript several ways:

num = parseInt(elem.value, 10)
num = +elem.value;
num = parseFloat(elem.value);
Sign up to request clarification or add additional context in comments.

Comments

0

I usually use:

num = elem.value * 1;

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.