[thelist] Js change mailto

Tom Dell'Aringa pixelmech at yahoo.com
Sat Sep 28 11:32:03 CDT 2002


--- fstorr <fffrancis at fstorr.demon.co.uk> wrote:
> Don't worry, I did it myself!
>
> Here it is - if there's a better way, I'm interested!

> <script type="text/javascript">
>
> function formcheck()
> {
>
> 	if (document.letter1.userurgent.checked)
> 	{
> 		document.all.addresscheck.href="mailto:urgent at bar.com";
> 	}
> 	else
> 	{
> 		document.all.addresscheck.href="mailto:normal at foo.com";
> 	}
> return false
> }
> </script>

One thing I would suggest is something like this:

function formcheck()
{
  if (!document.forms["letter1"].useragent.checked)
  {
    document.forms["letter1"].action="mailto:normal at foo.com";
    return;
  }
document.forms["letter1"].action="mailto:urgent at foo.com";
}

This saves you on the else clause. Its picky I know, but someone once
told me this was the "proper" way to do things (I believe he had a C
background)..anyway, I liked the idea and use it myself - its merely
a suggestion.

The argument could be made its slightly less readable for beginning
coders..don't know if you care about that :) This could be done the
other way around without the "not" in front..either way works.

I'm guessing this might spark a debate...

Tom


=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



More information about the thelist mailing list