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

Make "Surfers" key in something if they select Other...

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Here is my code: using Front Page 2000 and VBScript.<br><br>I have an drop down Option box that has &quot;Where did you hear about us&quot; selections in it. I have &quot;Other...&quot; at the bottom of the list.<br>&quot;Other&quot; is coming up more that we would like. I would like them to add where the &quot;Other&quot; came from in the comments section. <br>Any Ideas in VBscript how to check the Dropdown selection after they click it and pick &quot;Other&quot; to pop up a Message and even put the cursor blinking in comments.<br><br>TIA<br><br>&lt;/script&gt;&lt;!--webbot BOT=&quot;GeneratedScript&quot; endspan --&gt;&lt;form action=&quot;thankyou.asp&quot; method=get name=&quot;FrontPage_Form1&quot;&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;_borders/logo2000_tagline2.jpg&quot; alt=&quot;Universal Labeling Systems, Inc.&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&lt;font size=&quot;2&quot;&gt;&lt;strong&gt;Brochure Request Form.  &lt;/strong&gt;&lt;/font&gt;&lt;a href=&quot;index.html&quot;&gt;&lt;img src=&quot;_borders/return_home.gif&quot; alt=&quot;Return to Universal Home Page&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;font size=&quot;2&quot;&gt;&lt;strong&gt;&lt;br&gt;<br>&nbsp;&nbsp;Please complete the following and receive a free brochure. <br>&nbsp;&nbsp;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;   First Name &lt;input type=&quot;text&quot; name=&quot;Firstname&quot; size=&quot;20&quot;&gt;<br>&nbsp;&nbsp;Last Name &lt;input type=&quot;text&quot; name=&quot;LastName&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;          Company &lt;input type=&quot;text&quot; name=&quot;Company&quot; size=&quot;32&quot;&gt;<br>&nbsp;&nbsp;Title&lt;input type=&quot;text&quot; name=&quot;Title&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;               <br>&nbsp;&nbsp;Address &lt;input type=&quot;text&quot; name=&quot;Address&quot; size=&quot;20&quot;&gt; City &lt;input type=&quot;text&quot; name=&quot;City&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;           State&lt;input type=&quot;text&quot; name=&quot;State&quot; size=&quot;5&quot;&gt; Zip &lt;input type=&quot;text&quot; name=&quot;ZipCode&quot; size=&quot;14&quot;&gt;<br>&nbsp;&nbsp;Country &lt;input type=&quot;text&quot; name=&quot;Country&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp; Phone&lt;input type=&quot;text&quot; name=&quot;Phone&quot; size=&quot;15&quot;&gt; FAX &lt;input type=&quot;text&quot; name=&quot;Fax&quot; size=&quot;17&quot;&gt;<br>&nbsp;&nbsp;E-mail &lt;input type=&quot;text&quot; name=&quot;Email&quot; size=&quot;28&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp; How did you here about us? &lt;!--webbot bot=&quot;Validation&quot;<br>&nbsp;&nbsp;B-Disallow-First-Item=&quot;TRUE&quot; --&gt; &lt;select size=&quot;1&quot; name=&quot;HereAboutUS&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option selected&gt;Choose One...&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Food & Drug Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packaging Digest Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packagingnetwork.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packaging World Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Pack Expo.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Thomas Register Catalog&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Thomasregister.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Referral&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Other...&lt;/option&gt;<br>&nbsp;&nbsp;&lt;/select&gt;&lt;br&gt;<br>&nbsp;&nbsp;&lt;font face=&quot;Arial&quot;&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt; &lt;font size=&quot;2&quot;&gt;Comments:&lt;/font&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;font size=&quot;2&quot;&gt;<br>&nbsp;&nbsp;&lt;/font&gt;&lt;/font&gt;&lt;textarea rows=&quot;3&quot; name=&quot;Comments&quot; cols=&quot;56&quot;&gt; <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Hi,<br><br>You need to use java script to achieve this.<br><br>The only way, to do this in vbscript is to have a server side validation. It will prompt the surfer to enter the comment field if they chose the &quot;other&quot; option<br><br>Hope this answers your question <p>din<br><a href=mailto:tidrus@bigfoot.com>tidrus@bigfoot.com</a><br><a href= > </a><br>ICQ # 26094048
 
Yes I know that much..<br>Does any one have some VBScript to get me started<br><br>Function I_Checked_Other()<br><br>End function<br><br>Like so;<br><br>How to I know they clicked the &quot;Other&quot; word in th esame .ASP page and prompthe them with a message box and then maybe put the cursor blinking in the comments box?<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Use <br><br>&lt;option value=&quot;Other&quot;&gt; Other.... &lt;/option&gt;<br><br>in VbScript or Javascript:<br><br>Function I_Checked_Other()<br><br>if Document.FrontPage_Form1.HereAboutUS.value = &quot;Other&quot; then<br>&nbsp;MsgBox &quot; Please enter data in comments field&quot;<br>&nbsp;setfocus(comments) 'i am not sure in vbscript but in <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' javascript comments.setfocus;<br>end if<br><br>End function<br><br><br>Hope this will help you<br> <p>Anand Mishra<br><a href=mailto:anandm@entcomm.com>anandm@entcomm.com</a><br><a href= > </a><br>
 
OK great but how do I call the function?<br>I put it under the Option Other.<br>But when I pick Other and hit submit it ignores and goes to the next page.<br>Here's the whole page:<br>-------------------------<br>&lt;html&gt;<br>&lt;%@ Language=VBScript %&gt; <br>&lt;head&gt;<br><br>&lt;title&gt;Brochure Request&lt;/title&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>&lt;%<br> Set Conn = server.CreateObject(&quot;ADODB.Connection&quot;)<br> Conn.Open &quot;driver=SQL Server;server=clh.ij.net;uid=universal1;pwd=ULS1;database=Universal1;&quot;<br> Set RS = Conn.Execute(&quot;SELECT Brochure FROM [HitCounter]&quot;)<br>&nbsp;&nbsp;&nbsp;Set RS3 = Conn.Execute(&quot;SELECT * FROM [HearAboutUs] Order By Location&quot;)<br><br> Hit=RS(&quot;Brochure&quot;)<br> Temp = RS(&quot;Brochure&quot;) + 1<br><br> Set RS2 = Conn.Execute(&quot;UPDATE dbo.HitCounter SET Brochure = &quot; & Temp )<br>%&gt;<br><br>&lt;!--webbot BOT=&quot;GeneratedScript&quot; PREVIEW=&quot; &quot; startspan --&gt;&lt;script Language=&quot;VBScript&quot;&gt;&lt;!--<br>function FrontPage_Form1_onsubmit()<br>&nbsp;&nbsp;Set theForm = document.FrontPage_Form1<br><br>&nbsp;&nbsp;If (theForm.HereAboutUS.selectedIndex = 0) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;The first &quot;&quot;HereAboutUS&quot;&quot; option is not a valid selection.&nbsp;&nbsp;Please choose one of the other options.&quot;, 0, &quot;Validation Error&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;theForm.HereAboutUS.focus()<br>&nbsp;&nbsp;&nbsp;&nbsp;FrontPage_Form1_onsubmit = False<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;End If<br>&nbsp;&nbsp;FrontPage_Form1_onsubmit = True <br>End Function<br>--&gt;&lt;/script&gt;&lt;!--webbot BOT=&quot;GeneratedScript&quot; endspan --&gt;&lt;form action=&quot;thankyou.asp&quot; method=get name=&quot;FrontPage_Form1&quot;&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;_borders/logo2000_tagline2.jpg&quot; alt=&quot;Universal Labeling Systems, Inc.&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&lt;font size=&quot;2&quot;&gt;&lt;strong&gt;Brochure Request Form.&nbsp;&nbsp;&lt;/strong&gt;&lt;/font&gt;&lt;a href=&quot;index.html&quot;&gt;&lt;img src=&quot;_borders/return_home.gif&quot; alt=&quot;Return to Universal Home Page&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;font size=&quot;2&quot;&gt;&lt;strong&gt;&lt;br&gt;<br>&nbsp;&nbsp;Please complete the following and receive a free brochure.&nbsp;<br>&nbsp;&nbsp;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&nbsp;&nbsp;&nbsp;First Name &lt;input type=&quot;text&quot; name=&quot;Firstname&quot; size=&quot;20&quot;&gt;<br>&nbsp;&nbsp;Last Name &lt;input type=&quot;text&quot; name=&quot;LastName&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Company &lt;input type=&quot;text&quot; name=&quot;Company&quot; size=&quot;32&quot;&gt;<br>&nbsp;&nbsp;Title&lt;input type=&quot;text&quot; name=&quot;Title&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;Address &lt;input type=&quot;text&quot; name=&quot;Address&quot; size=&quot;20&quot;&gt; City &lt;input type=&quot;text&quot; name=&quot;City&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&lt;input type=&quot;text&quot; name=&quot;State&quot; size=&quot;5&quot;&gt; Zip &lt;input type=&quot;text&quot; name=&quot;ZipCode&quot; size=&quot;14&quot;&gt;<br>&nbsp;&nbsp;Country &lt;input type=&quot;text&quot; name=&quot;Country&quot; size=&quot;20&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;Phone&lt;input type=&quot;text&quot; name=&quot;Phone&quot; size=&quot;15&quot;&gt; FAX &lt;input type=&quot;text&quot; name=&quot;Fax&quot; size=&quot;17&quot;&gt;<br>&nbsp;&nbsp;E-mail &lt;input type=&quot;text&quot; name=&quot;Email&quot; size=&quot;28&quot;&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;How did you here about us? &lt;!--webbot bot=&quot;Validation&quot;<br>&nbsp;&nbsp;B-Disallow-First-Item=&quot;TRUE&quot; --&gt; &lt;select size=&quot;1&quot; name=&quot;HereAboutUS&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option selected&gt;Choose One...&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Food &amp; Drug Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packaging Digest Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packagingnetwork.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Packaging World Magazine&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Pack Expo.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Thomas Register Catalog&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Thomasregister.com&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Referral&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&gt;Other...&lt;/option&gt;<br>&nbsp;&nbsp;&lt;/select&gt;&lt;br&gt;<br>&nbsp;&nbsp;&lt;%Function I_Checked_Other()<br> If Document.formSQL3.HereAboutUS.value = &quot;Other&quot; then<br>&nbsp; MsgBox &quot; Please enter data in comments field&quot;<br>&nbsp; &nbsp;&nbsp;&nbsp;comments.setfocus<br> End if<br>&nbsp;&nbsp;End function%&gt;<br>&nbsp;&nbsp;&lt;font face=&quot;Arial&quot;&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;&nbsp;&lt;font size=&quot;2&quot;&gt;Comments:&lt;/font&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;font size=&quot;2&quot;&gt;<br>&nbsp;&nbsp;&lt;/font&gt;&lt;/font&gt;&lt;textarea rows=&quot;3&quot; name=&quot;Comments&quot; cols=&quot;56&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;input type=&quot;hidden&quot; name=&quot;Counter&quot; value=&quot;&lt;%=Hit%&gt;&quot;<br>&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;Respond&quot;&gt;<br>&nbsp;&nbsp;&lt;input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;&gt; &nbsp;&nbsp;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;[Page Counter &lt;%=Hit%&gt;]<br>&lt;/form&gt;<br>&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;_borders/webspacer2000.gif&quot; WIDTH=&quot;664&quot; HEIGHT=&quot;20&quot;&gt; &lt;/p&gt;<br>-------------------------------------<br><br>TIA<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Let me know if this doesn't work . . .

<HEAD>
<STYLE type=&quot;text/css&quot;>
.addons {
position: relative;
visibility: hidden;
}
</STYLE>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
var Ver4 = parseInt(navigator.appVersion) >= 4
var Nav4 = ((navigator.appName == &quot;Netscape&quot;) && Ver4)
var IE4 = ((navigator.userAgent.indexOf(&quot;MSIE&quot;) != -1) && Ver4)

function flip(block,sel) {
if (Nav4){
document.layers[block].visibility=(sel.options[sel.selectedIndex].value==&quot;Other&quot;) ? &quot;visible&quot; : &quot;hidden&quot;
}
else if(IE4) {
document.all(block).style.visibility = (sel.options[sel.selectedIndex].value==&quot;Other&quot;) ? &quot;visible&quot; : &quot;hidden&quot;
}
}
//-->
</SCRIPT>
</HEAD>

<BODY>

<SELECT NAME='State' TABINDEX='6' onChange=&quot;flip('reasonBlock',this);&quot;>
<OPTION VALUE='none' SELECTED>State</OPTION>
<OPTION VALUE='AL'>Alabama</OPTION>
<OPTION VALUE='AK'>Alaska</OPTION>
<OPTION VALUE='AS'>American Samoa</OPTION>
<OPTION VALUE='AZ'>Arizona</OPTION>
<OPTION VALUE='AR'>Arkansas</OPTION>
<OPTION VALUE='Other'>Other</OPTION>
</SELECT>
<SPAN ID='reasonBlock' CLASS='addons'>
<INPUT TYPE='text' NAME='state2' SIZE='25' VALUE='' MAXLENGTH='20' TABINDEX='7'>
</SPAN>

</BODY>

-Ivan
 
Oops . . . I just realized the date on this post . . . better late than never . . . lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top