|
-
Nov 21st, 2005, 09:26 PM
#2
Fanatic Member
Re: [Javascript] ComboBox (textbox and select in one)
Hi,
you cant do this in javascript as if you try adn write to the document using any kind of document write format, itll throw a method operator error.
Hees the one I wrote for a project. uses ASP and simple VBscript.
HTML Code:
<SELECT id="Tools" style="WIDTH: 116px;" name="tools">
<option value="" SELECTED>Select and Add</option>
<option value="None">Nothing</option>
<OPTION value="Microwave">Microwave</OPTION>
<option value="Toaster">Toaster Oven</option>
<option value="Coffee">Coffee Pot</option>
<option value="Skillett">Electric Skillet</option>
<option value="Demo Table">Demo Table</option>
<option value="Military Access">Military Access</option></SELECT>
<input name="ADD_T" type="submit" value="Add>>" />
<TEXTAREA id="Tools" style="WIDTH: 176px; HEIGHT: 45px" name="ToolBox" rows="2" cols="19"><% call ToolsDisplay() %></TEXTAREA>
so youve got a select box, submit button and text box to stor the info
now heres the function to write the info.
VB Code:
session("Tools") = Request.Form("ToolBox") // textarea form element
private function ToolsDisplay()
// if the form is submitted and button is not pressed, code wwrites the //session contents into the textarea, errorhandling code for form
// kickbacks
if (Request.form("ADD_T") = "") then
with response
.write Session.contents("Tools")
end with
end if
// writes the current selection of the select box
if (Request.Form("ADD_T") <> "") then
with response
.write Request.Form("tools")
end with
end if
end function
This code will write th ecurent selection of the select box into the textarea
when pressed, adn when other parts of the form are working, suhch as
a primary submit button, the textarea will show the current session contents, which is collected form the text are when a value is written into the textare.
Therefore this creates a loop where if a person selects 1 set of data, then goes back and select another
the data will be collated rather than overritten.
Its a nice bit of code, althouh a tad convaluted, but neccesssary for optimal performance.
Hope it helps
Kai
As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..
A few things that make a good Developer a Great One.
Methodical and a thorough approach to research and design inevitably leads to success.
Forward thinking is the key to Flow of control.
Never test in the design environment, always test in real time, you get the REAL results.
CBSE & OOSE are the same animal, they just require different techniques, and thinking.
SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
The key to good design is explicit attention to both detail and response.
Think Freely out of the "Box" you're in..... You will soar to better heights.
Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|