M
Melbfella
G'day all
I apologise in advance for the newbiness of this question, but the
answer has eluded me for 3 days now - hopefully one of you gurus out
there might be able to help .......
I have a page that dynamically draws checkboxes and am attempting to
use the following code to iterate through each text box, see if it's
checked - if checked, change a combo box to match the number typed in
a checkbox. Here's the code that calls the functions, and the
functions themselves......
**Code that fires the event
<input class="ctlstandard" type="text" name="txtSeats" id="txtSeats"
onblur="calculateCost();setOptionCombos();"/> <font color="<
%=session("BrandTextColour")%>">*</font></td>
<input type="checkbox"
onclick="showHideJumpPoints(this);calculateCost();" name="chkOption"
value="<%=rs("TourOptionID")%>"/>
**The functions
function calculateCost(){
var dblCost=0;
var lSeats=frmMain.txtSeats.value;
//alert('calc Cost');
if(isNaN(lSeats)){
document.all.txtSeats.focus;
alert('Please enter a number in the seats field');
}
dblCost=lSeats*frmMain.txtTourCost.value;
for (i=0;i<frmMain.chkOption.length;i++){
if (frmMain.chkOption.checked==true){
alert(frmMain.chkOption.value);
dblCost =dblCost +
(frmMain.cboTourOptionQty.value*parseInt(frmMain.txtOptionCost.value));
//alert('This option is checked');
//break //exist for loop, as target acquired.
}
}
document.getElementById('TotalCost').innerHTML='<b>$' +
CurrencyFormatted(dblCost) + '</b>';
}
function setOptionCombos(){
var lSeats=frmMain.txtSeats.value;
for (i=0;i<frmMain.cboTourOptionQty.length;i++){
frmMain.cboTourOptionQty.selectedIndex=lSeats-1;
}
}
This works if there are two checkboxes on the screen, but does not
when there's only one.
Any help or thoughts would be greatly appreciated
Cheers,
Doug.
I apologise in advance for the newbiness of this question, but the
answer has eluded me for 3 days now - hopefully one of you gurus out
there might be able to help .......
I have a page that dynamically draws checkboxes and am attempting to
use the following code to iterate through each text box, see if it's
checked - if checked, change a combo box to match the number typed in
a checkbox. Here's the code that calls the functions, and the
functions themselves......
**Code that fires the event
<input class="ctlstandard" type="text" name="txtSeats" id="txtSeats"
onblur="calculateCost();setOptionCombos();"/> <font color="<
%=session("BrandTextColour")%>">*</font></td>
<input type="checkbox"
onclick="showHideJumpPoints(this);calculateCost();" name="chkOption"
value="<%=rs("TourOptionID")%>"/>
**The functions
function calculateCost(){
var dblCost=0;
var lSeats=frmMain.txtSeats.value;
//alert('calc Cost');
if(isNaN(lSeats)){
document.all.txtSeats.focus;
alert('Please enter a number in the seats field');
}
dblCost=lSeats*frmMain.txtTourCost.value;
for (i=0;i<frmMain.chkOption.length;i++){
if (frmMain.chkOption.checked==true){
alert(frmMain.chkOption.value);
dblCost =dblCost +
(frmMain.cboTourOptionQty.value*parseInt(frmMain.txtOptionCost.value));
//alert('This option is checked');
//break //exist for loop, as target acquired.
}
}
document.getElementById('TotalCost').innerHTML='<b>$' +
CurrencyFormatted(dblCost) + '</b>';
}
function setOptionCombos(){
var lSeats=frmMain.txtSeats.value;
for (i=0;i<frmMain.cboTourOptionQty.length;i++){
frmMain.cboTourOptionQty.selectedIndex=lSeats-1;
}
}
This works if there are two checkboxes on the screen, but does not
when there's only one.
Any help or thoughts would be greatly appreciated
Cheers,
Doug.