/    Sign up×
Community /Pin to ProfileBookmark

Just Sharing: How to set an INPUT tag MAILTO value, using form field data

I hope I am doing this in the appropriate way. I was able to solve the problem I had yesterday and wanted to share my results with anyone else who might benefit from them.

I also wanted to thank Ultimater for being so kind in helping me.

What I was trying to do was figure out a way, using JS, to have Mailto value in a tag like this <input type=”hidden” name=”mailto” value=””> be populated with email addresses entered in other form fields by users. I hope that’s clearer than mud. Anyway, it may be sloppy, but it works.

The 2 fields in my form are called: CCEMAIL & RequesterEmail

Here is the JavaScript. I entered it into a function I was already using to validate form fields:

var ccURL = Contract.ccemail.value;
Contract.mailcc.value = ccURL;
var URL = Contract.RequesterEmail.value;
Contract.mailto.value = URL;

I called this function in the FORM tag, using onSubmit.

Here are my 2 input tags. I placed them at the bottom, just before the </form> tag.

<input type=”hidden” name=”mailto” value=””>
<input type=”hidden” name=”mailcc” value=””>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @jayhuck spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...