Article ID: 170495
Article Last Modified on 8/27/2007
APPLIES TO
- Microsoft FrontPage 97 Standard Edition
This article was previously published under Q170495
SUMMARY
This article provides a sample Visual Basic Script that calculates the contents of a drop-down list and displays the results in a text box.
MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To create a sample Visual Basic scripting program to add the contents of multiple drop-down menus, follow these steps:
- In FrontPage Explorer, open or create a Web.
- Open a Web page in FrontPage Editor.
- Insert the following form fields, by pointing to Form Field on the Insert menu, and then clicking the appropriate command:
Two drop-down menus
One one-line text box
One push button - Right-click the first drop-down menu form field and then click Form Field Properties.
- In the Name box, type the following name, and then click OK:
Drop1
Repeat steps 4 and 5 for the remaining form fields. Use the following names:
Object Name ------------------------------------- Second Drop-Down Menu Drop2 One One Line Text Box Text1 One Push Button Button1
- Right-click the first drop-down menu form field, and then click Form Field Properties.
- In the Drop-down Menu Properties dialog box, click Add.
- In the Add Choice dialog box, enter a number in the Choice box, and then click OK.
- Repeat steps 8 and 9 for each additional number you want to enter.
- Repeat steps 7 through 10 for the second drop-down form field.
- Right-click the push button form field and then click Form Field Properties.
- Click Normal, and then click OK.
- On the Insert menu, click Script.
- Click to select the VBScript check box.
In the Script box, type the following code:
sub button1_onclick ' Create the form object. dim theform set theform = document.form1 ' Return the value from the first drop-down menu. Drop-down text ' boxes return values as text. The Cint function converts text ' into an integer. firstvalue = Cint(theform.drop1.options _ (theform.drop1.selectedindex).text) ' Return the value from the second drop-down menu. secondvalue = Cint(theform.drop2.options _ (theform.drop2.selectedindex).text) ' Display the results in a text box. theform.Text1.value = firstvalue + secondvalue end sub
- Click OK.
- Save the file and preview it in your Web browser.
For additional information about Microsoft Visual Basic Scripting, please see the following Microsoft Web site:
Additional query words: 97 fpscript
Keywords: kbhowto kbusage KB170495