how do i call a field of a form on the current page, within ASP code?
eg.
<% sqlstring = "SELECT DISTINCT interest FROM main WHERE (interest Is Not Null AND type = " & [field on form] & " ORDER BY main.interest;"
I've done a something similiar by setting the SQL text to a DTC recordset by a value passed by a form. But I am really not sure about the code for your sqlstring because I am really new to sql. I do know however that you can get the value of a field on a form on a previous page by doing the following.
formfieldvar = Request("frmfield"
'frmfield being the field on the form on the previous page
On the previous page containing the form you would need to do:
thisform.action = "Second.asp"
thisform.submit
i want to resubmit a page, and calculate a value of a second list box - filled with data from database, based on the value selected in the first list box.
thanks
Sounds like your are trying do so something similiar to what I have here?
Sub CatRecordset_onbeforeopen()
cHoldcat = Request("Catlstbx"
'Catlstbx is the listbox on ASP1.asp
strSQL= "SELECT Subject AS Subject, StartDate AS [Start Date], StartTime AS [Start Time] FROM infotable WHERE (Category = '" & cHoldcat & "')
I haven't every used this method, but I did get it from the Help with Visual Studio. Maybe you can use it.
Listbox DTC help.
getValue Method
Returns a value from an object.
Syntax
object.getValue([nIndex | strField])
Parameters
object
A script object.
nIndex
Index of an item in the zero-based list. If left null, the index defaults to the currently selected item. The index of the currently selected item is equivalent to the value of the selectedIndex property.
strField
A string of the field name.
Remarks
For Listbox and OptionGroup objects, the method returns a text string that corresponds to the HTML attribute VALUE.
For the fields object, the method returns the value of the field for the current record.
Note For the OptionGroup object and ASP pages, there is an another way to return the value setting. You can reference an OptionGroup object by using its name with "_value" appended to it. For example, you could pass the value from an OptionGroup whose id is "myOptionGroup" by calling:
myVar = request("myOptionGroup_value"
In the scripting object model, you could return the same result with:
myVar = myOptionGroup.getValue()
More Help
Listbox Design-Time Control
Creates a Listbox script object, which creates an intrinsic HTML list box that can be bound to data.
Remarks
You can set the properties of the Listbox control at design time using the Properties window and the Listbox Properties dialog box.
Set the ControlStyle property to create a standard list box or a drop-down list box.
You can bind the Listbox control to one recordset and populate the list from another recordset by doing a lookup on the Lookup tab of the Listbox Properties dialog box.
If you want to create a static list instead of one that is data-bound, select the Static list option on the Lookup tab.
Note The scripting platform specifies where an object's script is run - either on the client (Microsoft® Internet Explorer 4.0 DHTML) or on the server (ASP). Thus, the scripting platform determines whether the object is available under Client Objects & Events or Server Objects & Events in the Script Outline window.
For the Listbox control, the Scripting Platform property is specified on the General tab of the Listbox Properties dialog box. For more information, see theDTCScriptingPlatform property. For detailed information about choosing a scripting platform, see Writing Script for Script Objects.
Scripting Notes
Call the hide, show, and isVisible methods to control how the list box is displayed.
To change the items of the Listbox object, call the addItem, removeItem, clear, and getCount methods.
To manipulate the current item, call the getValue, setValue, getText, and setText methods.
Call the selectByValue or selectByText methods to select an item in the list.
For more information about the run-time object, see Listbox Script Object. For information on scripting and objects, see Scripting with Design-Time Controls and Script Objects.
So that when a user makes a choice, the form submits itself, the page reloads, you retrieve the value as people have suggested above, and populate your second <select> based on that value.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.