Answered
CF variable in Javascript?
I have a series of forms for a shopping cart checkout. The
way the client has it setup, the user fills out a form with their
name, address, etc and then goes to a page to select payment
method. If credit card is selected, a form with standard CC number,
exp. date comes up. Also on this page, the user fills out the
billing address. There is a check box for if the billing address is
the same the the user's address. I need for the billing form to be
auto-filled if the checkbox is selected.
I know how to do this if the 2 forms are on the same screen, but in this case the first form is filled out previously. The info from the first form is in a table, so I can query the database to get the address information. But how do I get these ColdFusion variables into the Javascript? JS is not my strong suit, but here is a script I've used before:
<script language="JavaScript">
function useBillInfo(form)
{
var idx;
{
form.ShipTo_Name_First.value= form.BillTo_Name_First.value;
form.ShipTo_Name_Last.value = form.BillTo_Name_Last.value;
form.ShipTo_Address.value = form.BillTo_Address.value;
form.ShipTo_City.value = form.BillTo_City.value;
}
}
</script>
and then use this in the form as the checkbox code:
<input onClick="useBillInfo(this.form)" type="checkbox" value="1" name="ship_usebill" >
So what I really need is a clue on how to assign the "form.ShipTo_Name_First.value" in the Javascript to be equal to a CF variable pulled from a CFquery.
Hope this makes sense, and thanks in advance for your help!
A.L.
I know how to do this if the 2 forms are on the same screen, but in this case the first form is filled out previously. The info from the first form is in a table, so I can query the database to get the address information. But how do I get these ColdFusion variables into the Javascript? JS is not my strong suit, but here is a script I've used before:
<script language="JavaScript">
function useBillInfo(form)
{
var idx;
{
form.ShipTo_Name_First.value= form.BillTo_Name_First.value;
form.ShipTo_Name_Last.value = form.BillTo_Name_Last.value;
form.ShipTo_Address.value = form.BillTo_Address.value;
form.ShipTo_City.value = form.BillTo_City.value;
}
}
</script>
and then use this in the form as the checkbox code:
<input onClick="useBillInfo(this.form)" type="checkbox" value="1" name="ship_usebill" >
So what I really need is a clue on how to assign the "form.ShipTo_Name_First.value" in the Javascript to be equal to a CF variable pulled from a CFquery.
Hope this makes sense, and thanks in advance for your help!
A.L.
