SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Aug 25, 2003, 19:43 #1
- Join Date
- Mar 2003
- Location
- Melbourne, Australia
- Posts
- 463
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
display html depending on selected items in listbox
hi all
i'm after some script to display some html depending on what
is selected in a list box
the html i want to display are checkboxes so it's more stuff for a form
i'm using lotus notes, so i have to use javascript
i can get it to display a checkbox if a particular item is selected
but it won't show up in place, it loads a new page
with the check box the only thing on that new page
the code i'm using is very basic
Code:function updateChecks() { string = ""; if (document._WEBRequest.dataReq.value == "blah") { string = "<input type=\"checkbox\" name=\"check\" />"; string += "Boundary"; } return string; } function writeChecks() { document.write(updateChecks()); }
also don't have much clue as to how to make it show
more checkboxes if more than one item is selected in the listbox
thanks for any help
-
Aug 26, 2003, 08:56 #2
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
document.write(...) will always write to a new page once the original page has finished loading. What you want to do (if you want the checkboxes to appear on the same page) is use a div for the boxes to appear in and dHTML (document.layers, document.all, document.getElementById) to write to the div. (If interested, see the "dHTML: an Introduction" script/tutorial at my site -- GrassBlade)
Insofar as the multiple selections:
Code:function a(selObj) { for (var i =0;i < selObj.length;i++) if (selObj.options[i].selected) alert(selObj.options[i].value); } <select multiple onchange='a(this)'>
Where the World Once Stood
the blades of grass
cut me still
Bookmarks