html - Based on selection, "mailto:" link changes to "mailto: variable" using javascript -
i'm trying make form. way work user chooses option drop-down list. click confirm location button. click send email link. when click confirm location button, changes mailto link in send email link, based on selection in drop-down list. however, cannot figure how change mailto link mailto variable t holds value of email address (based on selection.) (see 3rd last line in code) please help!
<form>select place: <select id="myselect"> <option value="email@domain.com">location 1</option> <option value="email2@domain.com">location 2</option> <option value="email3@domain.com">location 3</option> <option value="email4@domain.com">location 4</option> </select> </form> <button type="button" onclick="displayresult()">confirm location</button> <a id="myemaillist" href="mailto:">send email</a> <script type="text/javascript"> function displayresult() { var x = document.getelementbyid("myselect"); t = x.value document.getelementbyid("myemaillist").href = "mailto:"t; } </script>
um, concatenate values?
document.getelementbyid("myemaillist").href = "mailto:"+t;
Comments
Post a Comment