Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-12-2009, 06:59 PM   PM User | #1
webmanSRS
New to the CF scene

 
Join Date: Mar 2009
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
webmanSRS is an unknown quantity at this point
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 = &quot;mailto:&quot; +
document.myform.mylist.options[document.myform.mylist.selectedIndex].value"
NAME="Send email">
</form>
webmanSRS is offline   Reply With Quote
Old 03-12-2009, 08:18 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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 = &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.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
webmanSRS (03-16-2009)
Old 03-13-2009, 03:27 AM   PM User | #3
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
Hi Philip,

Removing highlighted would do the same thing too:
Code:
<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
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Old 03-13-2009, 06:18 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Philip M (03-13-2009)
Old 03-13-2009, 06:28 AM   PM User | #5
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
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.
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Old 03-13-2009, 07:10 AM   PM User | #6
riwan
New Coder

 
Join Date: Aug 2008
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
riwan is an unknown quantity at this point
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..
riwan is offline   Reply With Quote
Old 03-13-2009, 07:14 AM   PM User | #7
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
Might shed some light:
http://www.w3schools.com/browsers/browsers_stats.asp
http://www.w3counter.com/globalstats.php
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Old 03-13-2009, 07:44 AM   PM User | #8
riwan
New Coder

 
Join Date: Aug 2008
Posts: 22
Thanks: 0
Thanked 2 Times in 2 Posts
riwan is an unknown quantity at this point
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
riwan is offline   Reply With Quote
Old 03-13-2009, 08:12 AM   PM User | #9
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
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).
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Old 03-13-2009, 08:51 AM   PM User | #10
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
See my book "How to write computer code succinctly and without being verbose", Volume 1, Chapert 27.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:13 AM.


Advertisement
Log in to turn off these ads.