The following code should update textboxes on all browsers that
support javascript. I've run into problems in the past trying to
get collections of objects to work...
<head>
<script type="text/javascript"><!-- //Hide from older browsers
var lngSelectedGood = -1;
var lngUnitPrice = 0;
var lngQty = 0;
var lngTotal = 0;
function fClearForm(form) {
form.txtUnitPrice.value = "";
form.txtQty.value = "";
form.txtTotalPrice.value = "";
return;
}
function fGoodSelected(form) {
var strTemp = "Blah!";
//var coll = document.all.tags("SELECT"); //PROBLEM SOME BROWSERS
fClearForm(form);
//strTemp = coll(0).options[lngSelectedGood].text; // this works but not used anymore
lngSelectedGood = parseInt(form.cmbSelectedGood.selectedIndex);
//we are opting to to identify by using document.FORMNAME.objectname
strTemp = document.Calculator.cmbSelectedGood.options[lngSelectedGood].text;
// if you had a text box to display what was selected...
form.txtSelectedGood.value = strTemp;
fCalculate(form);
}
function fCalculate(form) {
// someone types in a number
lngUnitPrice = parseInt(form.txtUnitPrice.value);
lngQty = parseInt(form.txtQty.value);
lngTotal = lngUnitPrice * lngQty;
return(lngTotal);
}
function fUpdateSCTFields(form) {
//an array holds info loaded up from a database
form.txtUnitPrice.value = parseInt(Goods[lngSelectedGood][0]);
form.txtShippingCost.value = parseInt(Goods[lngSelectedGood][1]);
return;
}
--></script>
</head>
<body>
<form name="Calculator">
<!-- The nice thing about combo boxes/list boxes denoted by
The first item in the collection of <select> objects is this one...
-->
<select name="cmbSelectedGood" tabindex="0" onchange="fGoodSelected(this.form)">
<option selected>Good #1</option>
.... more options / asp script to load up from db...
</select>
<input type="text" name="txtQty" size="5" value="0"
tabindex="1" MAXLENGTH="3"
onchange="fQtyChanged(this.form)" /><br />
<input type="text" name="txtUnitPrice" size="10" tabindex="12" disabled />
</form>
If you watch the flow of the code, I have one calculate function,
and the onchange="" items inside the combo boxes (or
listboxes) call functions to update disabled txtboxes <input> and
in the end call the fCalculate(form) function to calculate. I
shortened most of this code, but passing the form into the
functions works very well, function0001(this.form).
Also refering to document.FormName.objectName is a great
easy way to reference the objects. But you'll need to tag each
object with a name... (name="txtPrice"). The document is the
global tag in JavaScript used to reference the whole HTML
document. There is a form declaration (NOTE: the name is
case sensitive in all browsers when referencing it in JavaScript).
The Form Name is very important for all javascript code.
I've ran into some problems with javascript collections in the
past not working on NetScape browsers. That was a couple
years ago.
Hope that helps.
--
Jim Carlock
Post replies to newsgroup.
Again, thank you both for working on my problem.
I think i may not have explained it correctly. The problem is not in
passing the 1st and second forms data to the third form on the next page, but
rather what happens when the data gets to the peregform.asp page.
The page pe.asp has two forms, Form1 & Form2, which collect the district
number and club name and pass it on to the third page peregform.asp. Since i
don't have access to a Mac browser I have to guess at this, but I think that
part works fine, since it is server-side scripting. At least it works in all
cases where the Browser security is not set to "High".
The problems on the peregform.asp page are these:
1. when someone chooses one of the first set of options, the correct amount
for that option does not appear in the window. It should be either $250.00,
or $240.00, or $190.00, depending on whether you pick the 1st, 2nd, or 3rd
option. Additionally, if the 1st option is not chosen, then all of the
fields in the President-Elects section should be disabled, but that is not
being done on Mac browsers.
The same is true of the second set of options. The amount does not show in
the window here either. It should be $0.00 if the spouse is not registering,
or is registering seperately, and it should be $190.0 if the spouse is being
registered.
If the spouse is not being registered, the fields that collect his or her
name and club information are supposed to be disabled. Again this is not
being done on the MAcs.
The club and district number do not appear in the database on the Macs either.
Finally the Total registration which is derived from option 1 & 2 is not
being calculated at all.
In some netscape browsers the district and club appear correctly on the
form, but do not get posted to the database.
Would you please fill out the forms and submit them usine IE. and then do
the same thing with OSX and submit it.
You can then look at the results at:
http://www.rotary5830.org/Registrations/Bill/Reports/AllByDate.asp
Thanks again,