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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about requirement to execute a script.

Status
Not open for further replies.

LongFeiFengWu

Technical User
Nov 9, 2001
98
US
I have the following script (let's call it script1):

<script language=&quot;VBScript&quot;>
Sub B1_onclick

'MsgBox &quot;Did you make a sales attempt?&quot;,308
'IF 6 THEN Info.Submit()
'IF 7 THEN location.href &quot;toolmidtop_savenosale.asp&quot;

r = MsgBox (&quot;Did you make a sales attempt?&quot;,308)
IF r = 6 THEN Info.Submit()
IF r = 7 THEN location.href &quot;toolmidtop_savenosale.asp&quot;

End Sub

</script>

I also have this script let's call it script2:

<select size=&quot;1&quot; name=&quot;Work&quot; style=&quot;font-family: Arial; font-size: 8pt&quot;>
<%

SQL = &quot;SELECT * FROM unitDetails WHERE &quot;
SQL = SQL & &quot;Jurisdiction='ALL' &quot;
objrec.open SQL,objcon,3,3

do while not objrec.eof
response.write &quot;<option value='&quot; & objrec(&quot;ID&quot;) & &quot;'>&quot; & objrec(&quot;Type1&quot;)
If objrec(&quot;Type2&quot;) <>&quot;N/A&quot; then response.write &quot; - &quot; & objrec(&quot;Type2&quot;)
response.write &quot;</option>&quot;
objrec.movenext
loop


%>
</select></font></td>

What I want to have happen is for Script1 to execute only if obrec(&quot;Type2&quot;) from Script2 = Email. Anyway I can do that?


&quot;If nothing within you stays rigid, outward things will disclose themselves. Moving, be like water. Still, be like a mirror. Respond like an echo.&quot; ~ Bruce Lee
 
I don't know what B1 is, but my guess is that when the user clicks B1, the Sub B1_onclick will execute.

And it is not clear whether Sub B1_onclick is part of the HTML document you have generated and sent to the client, or is part of the ASP script. But it must be a client side script because there is no clicking when the ASP script is running. In that case I would guess that all of your users are running IE, because otherwise they won't have VBScript on their computers.

That said, all you need to do is test for Email when B1_onclick starts. If you have Email then perform the procedure, if not then skip over it and exit. In other words B1_onclick always executes, but sometimes it doesn't do anything.

Like so -
Code:
Sub B1_onclick

  Dim el, elValue, isEmail
  Set el = document.forms[0].Work
  elValue = el.options[el.selectedIndex].value
  
  isEmail = True
  If InStr(elValue, &quot;Email&quot;) = 0 Then isEmail = False
  
  If isEmail THEN
      
    'MsgBox &quot;Did you make a sales attempt?&quot;,308
    'IF 6 THEN Info.Submit()
    'IF 7 THEN location.href &quot;toolmidtop_savenosale.asp&quot;
    
    r = MsgBox (&quot;Did you make a sales attempt?&quot;,308)
    IF r = 6 THEN Info.Submit()
    IF r = 7 THEN location.href &quot;toolmidtop_savenosale.asp&quot;
   
  End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top