Javascript woes...
Posted: Wed Sep 26, 2007 3:48 pm
feyd | Please use
I hope I have this code quoting thing right...
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I've got a select list with 227 options. I want to eliminate the options that don't have documents associated with them. To do this I tagged the values of the options I want with 'HAS_DOCS'. I'll post the meat of the code and carve out the bulk of the 227 entries. The list is shortened when the 'Documents' radio button is clicked.
The problem is that it takes 5 clicks to get through the list. It's skipping some entries - always the same ones, but they're no different than the rest (I think). Does anyone see anything obvious in this code that would make the javascript not process the entire for loop?
Thanks.
Bob
[syntax="html"]
<head>
<script type="text/javascript">
function shrink_list() {
var form_len = document.forms['DOCGRPform'].DOCGRP_ID.options.length;
for (index = 0; index < form_len; index++) {
var curval = document.forms['DOCGRPform'].DOCGRP_ID.options[index].value;
if (curval.match("HAS_DOCS") == null) {
document.forms['DOCGRPform'].DOCGRP_ID.options[index] = null;
}
}
document.DOCGRPform.DOCGRP_ID.focus();
}
</script>
</head>
<table>
<tr>
<td valign="top">
<br>
<strong>Choose a Group to analyze</strong><br>
<form name="DOCGRPform"action="my_prog.php" method="POST">
<select name="DOCGRP_ID" >
<option value="4" >Public Site(4)</option>
<option value="5" >Secure Site(5)</option>
<option value="7" >Root(7)</option>
<option value="232HAS_DOCS" >Core 1*(232)</option>
<option value="231" >Reports(231)</option>
<option value="731HAS_DOCS" >Consortium*(731)</option>
<option value="2548HAS_DOCS" >EXPORT*(2548)</option>
</select>
</td>
<td><br><b>Display Choice</b><br>
<input type="radio" name="doc_or_user" value="Documents" onclick="shrink_list();"> Documents
<input type="radio" name="doc_or_user" checked="checked" value="Users"> Users (default)<br>
<input type="hidden" name="Context" value="Analyze">
<input name="submit" type="submit" value="Analyze This">
</td>
</form>
</tr>
</table>
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]