INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Adding an if statement

Adding an if statement

(OP)
Hello,

I inherited a web form and I am trying to make some changes. I am fairly new to programming and thus to JavaScript, I have been trying to modify a script that opens outlook and fills out the recipient, subject and email body. the idea is that the user revises the email before ending.

What I would like to add is an if statement so send to specific users if a specific field is picked

Here is what I have tried so far

original code

CODE

<script type=text/javascript>

function openoutlook()
{
  var S=document.form.company.value;
  var B=document.form.email.value;
  var M=document.form.csupdatedby.value;
  var A= <% = Cdbl((rsGuestbook("ID")))%>
  var url = 'http://mydomain.com/xx/view.asp?id=' + escape(A);

  
 self.location="mailto:mycustomlist@mydomain.com?subject=An New Entry Has Been Made To xx Form  "+A+" by "+M+" &body= Here is the link to the updated project  "+url;
}
</script> 

Modified code

CODE

<script type=text/javascript>

function openoutlook()
{
  var S=document.form.company.value;
  var B=document.form.email.value;
  var M=document.form.csupdatedby.value;
  var A= <% = Cdbl((rsGuestbook("ID")))%>
  var url = 'http://mydomain.com/xx/view.asp?id=' + escape(A);

if (csupdatedby == 'customer service') {
     self.location="mailto:cs@mydomain.com?subject=An New Entry Has Been Made To xx Form  "+A+" by "+M+" &body= Here is the link to the updated project  "+url;}
else if (csupdatedby == 'production') {
     self.location="mailto:production@mydomain.com?subject=An New Entry Has Been Made To xx Form  "+A+" by "+M+" &body= Here is the link to the updated project  "+url;}
else if (csupdatedby == 'QC') {
     self.location="mailto:qc@mydomain.com?subject=An New Entry Has Been Made To xx Form  "+A+" by "+M+" &body= Here is the link to the updated project  "+url;}
else if (csupdatedby == 'Accounting') {
     self.location="mailto:Accounting@mydomain.com?subject=An New Entry Has Been Made To xx Form  "+A+" by "+M+" &body= Here is the link to the updated project  "+url;}

  

}
</script> 

But this does not work, not sure where I am going wrong, any help is much appreciated!!

thanks!!

RE: Adding an if statement

Do you get any errors?

At first glance there is no variable called csupdatedby, so nothing to check against for your If statements.

Perhaps you meant: "M", or at the very least document.form.csupdatedby.value

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Adding an if statement

(OP)

vacunita thousand thanks!!! that was a huge oversight, even for a non programmer person.

I made the correction and seems to be working well. I appreciate you taking the time to look at my code.

Again,

Than you!!!

RE: Adding an if statement

Glad I could help.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close