...

View Full Version : Adding subject=



webmanSRS
03-12-2009, 07:59 PM
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 = &quot;mailto:&quot; +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value"
NAME="Send email">
</form>

Philip M
03-12-2009, 09:18 PM
Like 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 type="button" value="Send email"
onclick="location.href = &quot;mailto:&quot; +
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.

rangana
03-13-2009, 04:27 AM
Hi Philip,

Removing highlighted would do the same thing too:


<input type="button" value="Send email"
onclick="location.href = &quot;mailto:&quot; +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value + '?subject=' + 'Hi!'">


Just trying to poke in again :p

Old Pedant
03-13-2009, 07:18 AM
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.

rangana
03-13-2009, 07:28 AM
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.

riwan
03-13-2009, 08:10 AM
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.

rangana
03-13-2009, 08:14 AM
Might shed some light:
http://www.w3schools.com/browsers/browsers_stats.asp
http://www.w3counter.com/globalstats.php

riwan
03-13-2009, 08:44 AM
This would also shed some light:
http://www.w3schools.com/HTMLDOM/dom_obj_select.asp

As you see that in the select object property there is no 'value' property listed

rangana
03-13-2009, 09:12 AM
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).

Philip M
03-13-2009, 09:51 AM
See my book "How to write computer code succinctly and without being verbose", Volume 1, Chapert 27. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum