Click to See Complete Forum and Search --> : [RESOLVED] [Javascript] ComboBox (textbox and select in one)
oceanebelle
Nov 21st, 2005, 06:32 PM
How do I go about it?
:( I need Ideas.
kaihirst
Nov 21st, 2005, 08:26 PM
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.
<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.
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
oceanebelle
Nov 21st, 2005, 10:23 PM
thanks kai, though not what i need now already ehehehe, specs changes :)
kaihirst
Nov 22nd, 2005, 01:03 PM
OMG!!!! :eek: :eek: :eek: :eek:
Its a classic when that happens!!!
Wll.. you knwo for next time if you need it. Also
You can use the document.myform.submit() on the on change function in javascript for this if anybodies interested. But this might be confusing to your users as they might think on adding manually..
Kai
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.