Quick question on a confirm dialogue box function I am currently working on.
I have a form with a few text fields. These are:
Textfield 1: ID = "item"
Textfield 2: ID = "price"
Textfield 3: ID = "quantity"
Textfield 4: ID = "type" (Buy or Sell)
On the submit button, I have an onClick = 'calcFields();'
This calls up a function:
<script type="text/javascript">
function calcFields() {
confirm("Are you sure you want to place this order?");
}
</script>
Ok, so this actually works. The confirm box shows up, no problem. However, when I try to add stuff into the confirm box:
<script type="text/javascript">
function calcFields() {
var val1 = getDocumentById("price").value;
var val2 = getDocumentById("quantity).value;
var val3 = val1 * val2;
var valItem = getDocumentById("item").value;
var valType = getDocumentById("type").value;
confirm('Are you sure you want to ' + valType +
'units of ' + valItem + ' for $' + val3 + ' ?');
}
</script>
It breaks down completely. No confirm box, and the form submits itself. Any thoughts? Couldn't find a tutorial online to help solve this
I have a form with a few text fields. These are:
Textfield 1: ID = "item"
Textfield 2: ID = "price"
Textfield 3: ID = "quantity"
Textfield 4: ID = "type" (Buy or Sell)
On the submit button, I have an onClick = 'calcFields();'
This calls up a function:
<script type="text/javascript">
function calcFields() {
confirm("Are you sure you want to place this order?");
}
</script>
Ok, so this actually works. The confirm box shows up, no problem. However, when I try to add stuff into the confirm box:
<script type="text/javascript">
function calcFields() {
var val1 = getDocumentById("price").value;
var val2 = getDocumentById("quantity).value;
var val3 = val1 * val2;
var valItem = getDocumentById("item").value;
var valType = getDocumentById("type").value;
confirm('Are you sure you want to ' + valType +
'units of ' + valItem + ' for $' + val3 + ' ?');
}
</script>
It breaks down completely. No confirm box, and the form submits itself. Any thoughts? Couldn't find a tutorial online to help solve this