Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

why does it not work

<P>email:</P> <input id="myd" type="email" name="email"/>

<button onclick="myFunction();" id="myd">save</button>

<script> function myFunction(){ var email = document.getElementById("myd"); window.location.href = "mailto:" + email + "?subject=your order was prosesed"; } </script>

2 Answers

You seem to have the same id for both the input field, as well as the button.

Steven Parker
Steven Parker
231,072 Points

Each ID value on the page must be unique, and as Joris observed, you seem to have the same one used on different elements.

But another issue is that even if the correct element is selected, concatenating it with "mailto:" isn't going to create a string you could set the location with. You probably will want to use the value property of the element instead of the element itself.