Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-12-2009, 06:59 PM
PM User |
#1
New to the CF scene
Join Date: Mar 2009
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Adding subject=
How do I add subject=Hi to this?
<form NAME="myform">
<select SIZE="1" NAME="mylist">
<option value="bryan@psacake.com"> Bryan </option>
<option value="billg@microsoft.com"> Bill Gates </option>
<option value="president@whitehouse.gov"> President Clinton </option>
</select>
<input LANGUAGE="JavaScript" TYPE="button" VALUE="Send email"
ONCLICK="location.href = "mailto:" +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value"
NAME="Send email">
</form>
03-12-2009, 08:18 PM
PM User |
#2
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Like this:-
Code:
<form name="myform">
<select size="1" name="mylist">
<option value="bryan@psacake.com"> Bryan </option>
<option value="billg@microsoft.com"> Bill Gates </option>
<option value="president@whitehouse.gov"> President Clinton </option>
</select>
<input type="button" value="Send email"
onclick="location.href = "mailto:" +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value + '?subject=' + 'Hi!'">
</form>
Quizmaster: Which African country gives its name to the complaint known as 'gippy tummy'?
Contestant: Venezuela.
Users who have thanked Philip M for this post:
03-13-2009, 03:27 AM
PM User |
#3
Senior Coder
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
Hi Philip,
Removing highlighted would do the same thing too:
Code:
<input type="button" value="Send email"
onclick="location.href = "mailto:" +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value + '?subject=' + 'Hi!'">
Just trying to poke in again
03-13-2009, 06:18 AM
PM User |
#4
Supreme Master coder!
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
rangana: WRONG ANSWER!
*NOT* in all browsers!
Yes, in all MSIE. And yes, as some other browsers (e.g., FireFox) started copying MSIE. But several browsers still require the form that Philip showed.
Users who have thanked Old Pedant for this post:
03-13-2009, 06:28 AM
PM User |
#5
Senior Coder
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
Hi Old Pedant,
I've tested the code on:
IE7, Opera 9.5, Safari 3.2.1, Firefox 3.0.7 at the very least.
...and it works fine
Let me know as to which browsers does the modified code fails? I will totally appreciate any input you would shed.
03-13-2009, 07:10 AM
PM User |
#6
New Coder
Join Date: Aug 2008
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
I'm with Old Pedant side for this.
Being a web developer for years, I know that your code don't work for all browsers. You only got the code to work because you're using the latest version of browser, not all people are using the latest version yet.
There's a reason why everyone are using the long version instead of the shorter one.
Last edited by riwan; 03-13-2009 at 07:14 AM ..
03-13-2009, 07:14 AM
PM User |
#7
Senior Coder
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
03-13-2009, 08:12 AM
PM User |
#9
Senior Coder
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
Just like what PhilipM always say..."there's always more than one way to skin a cat".
If you prefer to get the value in that way, then so be it.
It's my own preference to get the option's value by using DOM 0 way of accessing elements. Straight-forward and less verbose (I believe).
03-13-2009, 08:51 AM
PM User |
#10
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
See my book "How to write computer code succinctly and without being verbose", Volume 1, Chapert 27.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 07:13 AM .
Advertisement
Log in to turn off these ads.