急需帮助
我有一个带有2个文本框的HTML页面,1个下拉列表和1个按钮,按钮点击我想打开电子邮件(目前我正在使用javascript),主题行是在下拉菜单中选择的任何内容写在文本框中。
<body>
<form id='sampleform' method='post' action='' >
Emp Number: <input type='text' name='empnum' />
</p>
<p>
Unit Name: <input type='text' name='unit' />
</p>
<p>
Type of subscription you want:
<p>
<select name="type">
<option value="standard">Standard - Free</option>
<option value="prof">Professional - Paid</option>
</select>
</p>
</p>
<p>
<input type='submit' name='Submit' value='Submit' onClick="parent.location='mailto:er.saurav1@gmail.com?subject=Thanks for writing &body=Hi,%0A%0CThanks for writing. We will get back to you soon. %0A%0C%0D%0AThanks and Regards,%0A%0CSaurav Kumar%0A%0C%0A%0CFor further assistance call 81111'">
</p>
</form>
</body>
我希望当我的电子邮件打开时,主题行输出应为:
Emp Num |单位名称|选定的价值 从下拉
答案 0 :(得分:1)
我重新编辑了Srikanth Rayabhagi的帖子。现在它应该工作
<script type='text/javascript'>
function sendMail(){
var form = document.forms.sampleform;
var empnum = form.empnum.value;
var uname = form.unit.value;
var ddvalue = form.type.options[form.type.selectedIndex].value;
var subj = empnum + '|' + uname + '|' + ddvalue;
parent.location='mailto:abc@gmail.com?subject=' + encodeURIComponent(subj) +'&body=Thanks for writing. We will get back to you soon';
}
</script>
只需在任何Button onClick事件中调用sendMail()。
HTH
答案 1 :(得分:0)
在onclick
:
var form = document.forms.sampleform;
var subject = form.empnum.value + ' | ' + form.unit.value + ' | ' + form.type.value;
parent.location = 'mailto:er.saurav1@gmail.com?subject=' + encodeURIComponent(subject) + '&body=...';
答案 2 :(得分:0)
<script type="text/javascript" charset="utf-8">
function click_handler(){
var x = document.forms.sampleform;
var enum = x.empnum.value;
var uname = x.unit.value;
var ddvalue = x.type.options[x.type.selectedIndex].value;
var subj = enum +'|'+uname+'|'+ddvalue;
parent.location='mailto:abc@gmail.com?subject=' + encodeURIComponent(subj) +'&body=Thanks for writing. We will get back to you soon';
}
</script>
<body>
<form id='sampleform' name='sampleform'>
Emp Number: <input type='text' name='empnum' />
</p>
<p>
Unit Name: <input type='text' name='unit' />
</p>
<p>
Type of subscription you want:
<p>
<select name="type">
<option value="standard">Standard - Free</option>
<option value="prof">Professional - Paid</option>
</select>
</p>
</p>
<p>
<input type='button' name='Submit' value='Submit' onClick="javascript:click_handler()">
</p>
</form>
</body>
</html>
会好的..虽然没有通过运行来检查..点击按钮时调用click_handler_me()
。