Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding an if statement 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
0
0
US
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 = '[URL unfurl="true"]http://mydomain.com/xx/view.asp?id='[/URL] + 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 = '[URL unfurl="true"]http://mydomain.com/xx/view.asp?id='[/URL] + 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!!
 
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
 

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!!!
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top