Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP variable added to javascript variable problem

Status
Not open for further replies.

scribbler

MIS
Feb 4, 2002
206
GB
I have posted this onto the Javascript forum but havent as yet received any help so as it involves both ASP and javascript I thought I'd add it here. So here goes....

Within my ASP pages I have been using javascript code supplied by Tek-Tips MVP's to caculate the total value of checkboxes "ttl" when checked, put this into text box4 and this worked fine, but I now need to add to this another box, "textbox5" which adds together this javascript total "ttl" and another variable from my ASP code. Firstly can this be done ? secondly I tried to do the following without success.

<script>
function calculate(inObj){
//Don't need to pass inObj here since it is not used in the function
ttl = 0
grandttl = 0
//sets the total couter to 0
allInput = document.getElementsByTagName("input")
//loads all INPUT elements into an array called "allInput"
for(x=0; x<allInput.length; x++){
//prepares to loop through the allInput array
if (allInput[x].type == "checkbox"){
//if the input type is a checkbox proceed
if (allInput[x].checked){
//if the checkbox is checked proceed
val = parseFloat(allInput[x].value)
//load the number value into a var called val
if (!isNaN(val)) ttl += val
//if val is a valid number (ie - not Not a Number) add it to the total
}
}
}
document.getElementById("box4").value = ttl
document.getElementById("box5").value = ttl + <%ASPvariable%>

//write the total to an input with the ID box4
}
</script>
 
Dunno if that will work in J/S but assuming it does not...Why don't you put the value in ASPvariable into a textbox..ie

<input type=hidden value=<%=ASPvariable%> >

and then reference that from your j/s just like you would any textbox

All hail the INTERWEB!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top