Emilio Yero
Emilio Yero

Reputation: 127

How to get inputs with specific values and put them into a text area in a form ?

I am trying to build an estimates page and need to send via email only the inputs with values different from zero.

How to get the input with values different from 0 in a form and sent them via email?

Upvotes: 2

Views: 48

Answers (1)

Adam Rackis
Adam Rackis

Reputation: 83356

You can select right against the value attribute like this

$("input[value!='0']");

Or if you ever need to query more robustly, you could use the filter function

$("input").filter(function() {
    return +$(this).val() > 0;
});

As far as sending emails, you'll need to post back to your server and put together an email manually. There's nothing in jQuery that'll do that for you.

If you were using .net, it might look something like this:

System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
Message.Body = String.Format("These are the inputs that were zero {0}", 
                    String.Join(",", PostedInputIdsOf0));
Message.To.Add("[email protected]");
new System.Net.Mail.SmtpClient("host address").Send(Message);

Upvotes: 2

Related Questions