Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Adding subject=

  1. #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 = &quot;mailto:&quot; +
    document.myform.mylist.options[document.myform.mylist.selectedIndex].value"
    NAME="Send email">
    </form>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 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 = &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.

  • Users who have thanked Philip M for this post:

    webmanSRS (03-16-2009)

  • #3
    Senior Coder rangana's Avatar
    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 = &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

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 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:

    Philip M (03-13-2009)

  • #5
    Senior Coder rangana's Avatar
    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.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #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.

  • #7
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #8
    New Coder
    Join Date
    Aug 2008
    Posts
    22
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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

  • #9
    Senior Coder rangana's Avatar
    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).
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    See my book "How to write computer code succinctly and without being verbose", Volume 1, Chapert 27.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •