Lasse,
Thanks so much for your help; it has been invaluable!! I have
uploaded the latest version, but a few things remain to be resolved:
1) I am trying to get the reset to function correctly by making all
reset including making your <tr id=hide> disappear if "suggest a
course" had been selected. The reset I have coded does what I want
but only after clicking it twice. Can it be coded to reset all after
one click?
2) Another on Experts-Exchange had suggested that I "don't use a
'static' index for comparison (unless it's '0') for the courses data
validation on the suggest input box because if you change the number
of available options, you will crash -- and six months from now you
will not know why:
so change this:
if(document.oracle.courses.options[18].selected)
{
to:
if(document.oracle.courses.options[somePassedNdx].value ==
'someFlag')
{:
How would I code the suggested above variables if the suggest course
is contained for each country? Here is the latest portion of this
code:
if (data.courses.options[18].selected) {
if (data.suggest.value == "") {
alert("Please enter a suggested course name.");
data.suggest.focus();
return false;
}
}
3) The same individual mentions the following to resolve my course
name passing for the results page:
"You asked, 'can I pass the associated array text value instead of the
number of the array'. Simply, create a hidden field, pass the text
value to the hidden field -- pick up the hidden field in the receiving
page and ignore the passed index"
How do I go about writing the hidden field portion so that it doesn't
matter which country array of data had been used?
Thanks again for all of your help; I am almost finished now!
Kevin
Lasse Reichstein Nielsen <lrn@hotpop.com> wrote in message news:<vfr43pik.fsf@hotpop.com>...[color=blue]
>
madforplaid@go.com (Kevin Lyons) writes:
>[color=green]
> > First of all, this is for an intranet site working in an IE
> > environment only, but I now have a few errors with other things that I
> > am trying to implement (which need fixing):[/color]
>
> I'll be testing in Opera 7.2, but I hope the results will work in IE
> too :)
>[color=green]
> > One, I still need to be able to pass in the correct courses value to
> > their results page. How can I populate the correct option values
> > within the JavaScript code?[/color]
>
> What is the correct courses value?
> As it is now, selecting a country and clicking on a product category adds
> one course. However, there is also a line with some Javascript, which looks
> like a bug.
>
> Checking... it is a bug.
> You write:
> ---
> <option>-- Available Courses --
> <script language="javascript" type="text/javascript">
> for (counter=0; ...
> ---
> While the end tag for option elements are optional, leaving them out
> can be ambiguous. Inside an option tag, you are only allowed to have
> *text*, not HTML. The script tag is technically inside the option element,
> so it is ignored, and the content is made part of the option text. If
> you add </option> at the end of the first line, it seems to work to me.
>
> I.e., it is an HTML problem.
>
> The script in the tag isn't too good either:
> ---
> for (counter=0; counter < Australia_Database.length; counter++) {
> document.write("<option value=counter>");
> }
> ---
> You write 16 times "<option value=counter>", options with the same
> value and no text. What you propbably meant to write is:
> document.write("<option value='" + counter + "'>" +
> Australia_Database[counter] + "<\/option>");
>
> (as a style note, I would drop the blank option in the country select, it
> looks weird, and is confuzing when you select using the keyboard).
>[color=green]
> > Two, I want to add hidden div tag code that will allow the use to
> > suggest a course if not listed within the drop-down list. If the 15th
> > element in the array is selected then the div should appear allowing
> > for input. This is not quite working correctly. For now, the div
> > code has been appearing whether or not the 15th element has been
> > selected.[/color]
>
> I guess the culprit is this function:
> ---
> function selectCourse() {
> if(document.oracle.courses.options[15].selected = true) {
> Hide.style.display="inline";
> }
> else {
> Hide.style.display="none";
> }
> }
> ---
> Where do I begin?
>
> I assume Hide is a global variable declared somewhere else to refer
> to the div with id="hide". Ok, I did, but now I have looked for it,
> and it isn't declared anywhere.
>
> You use "=" for comparison. It is actually assignment, so every time
> you change the selection, the element number 15 is selected again. For
> "Application Server", that is "Online Library", not "Suggest a
> Course". You have two lines at the begining of the select ("Select
> course" and a blank option (I don't like blank options!), so the
> 16th option you add has selectedIndex 17.
>
> This is also highly unstable code, since it depends on all categories
> having the same number of entries. What happens when a new Database
> coimes out, so there are 16 databases?
>
> Finally, the div itself is placed inside a table, wrapping a tr tag.
> That is not a legal position for a div, which you would know if your
> code validated (get your HTML code validating! It saves you and us
> so much trouble!). What you can do, is to move the id="hide" onto
> the tr tag itself: <tr id="hide" style="display:none;">, and drop the div.
>
> I recommend the following function:
> ---
> function selectCourse() {
> var Hide = document.getElementById("hide");
> var selRef = document.forms['oracle'].elements['courses'];
> if(selRef.selectedIndex == selRef.options.length-1) {
> Hide.style.display="";
> } else {
> Hide.style.display="none";
> }
> }
> ---
>[color=green]
> > Three, I am trying to add capabilities when clicking the text to the
> > right of the radio buttons that will accomplish the same as the actual
> > selection of the radio buttons to populate the courses accordingly.[/color]
>
> I don't think your changeRadio function is working. It might change
> the "checked" property of the radiobutton, but it won't call its
> onclick handler, so the courses aren't updated when you click on the
> label. Also, it uses "eval", which should almost never be used in
> practice.
>
> You call it as:
> onClick="changeRadio('document.oracle.products[1]')"
> Just remove the quotes, and send a reference to the element itself:
> onClick="changeRadio(document.forms['oracle'].elements['products'][1])"
> Then the code for the function would be:
> function changeRadio(val) {
> val.click();
> }
> It is a radio group. You don't want to be able to unselect all the elements,
> so no need for "val.checked = !val.checked". Also, this function is so
> simple, that you might as well inline it.
>
> Instead of using a span, you should use the element that is meant for
> exactly this: label.
>
> <label style="cursor:pointer;cursor:hand;"
> onclick="document.forms['oracle'].elements['products'][0].click()">
> <input type="radio" name="products" value="Database" onClick="loadOptions()">
> Database
> </label>
>
> (I always write my form references out with "forms" and "elements"
> collections.)
>
> You also use "eval" in one other place:
> category = eval(selectChoice + "_" + radioChoice);
> This can be changed to the much faster and non-eval-using:
> category = window[selectChoice + "_" + radioChoice];
>
> Good luck
> /L[/color]