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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing javascript variables to a function

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
US
Hello,
I am trying to unravel some code from a predecessor.

There is a function in the head tag.
Code:
<script>
function submitForm(){
  frm=self.document.Edit
//  alert('d_cnt ' + d_cnt)
//  alert('billto ' + billto)

if (  (Number(d_cnt)+Number(frm.order_quantity.value)) > 192 ) {
    alert("Order quantity exceeds calendar month limit of 192.")
    frm.order_quantity.focus()
    frm.order_quantity.select()
  } 
else {
    frm.submit()
  } 
}
</script>


The value d_cnt is pulled from a record set later in the file.


Code:
//connects to db, runs query
Write("<SCRIPT>var d_cnt="+icurs("d_cnt")+";</SCRIPT>")

I wanted to add another variable to pass to the same function from the same record set on the next line in the asp page.
Code:
Write("<SCRIPT>var billto="+icurs("Billto")+";</SCRIPT>")

It keeps showing as 'undefined' when I set an alert in the function to write the new variable out.

I am not really certain what this methodology is called in order to google it. What do I need to study/get advice on, to replicate this behavior with new variables. I am missing something elementary and can't get it to work.

Thanks
Patrick



 
Hi

What is the output of that line ?
Patrick said:
Write("<SCRIPT>var billto="+icurs("Billto")+";</SCRIPT>")
I mean, how it appears in the HTML document's source when you view it with the browser's View page source command ?



Feherke.
[link feherke.github.com/][/url]
 
feherke

Thank you. Just by asking that question, it showed me what was wrong. This variable needed to be a string, the 'view code' was showing with no quotes.

Thanks again.

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top