If an html element id has no period in it, then copying between elements is of course trivial, e.g.:
var theForm = document.paymentForm;
theForm.BillStreet1.value = theForm.ShipStreet1.value;
I’ve got a case where I need to have period in my ids, namely id=”bill.street1″ and id=”ship.street1″, and the following doesn’t work 🙁
theForm.bill.street1.value = theForm.ship.street1.value;
Can you please let me know how to handle the period? Does jquery make this simpler?
jQuery makes everything simplier by using css selectors to access elements. However, if you don’t want to use jQuery, you can access the element this way, I believe.
I haven’t tested this, but it should work because periods are an alternate method to access an array, iirc.
Be sure to use
theForm['bill.street1'].value = theForm['ship.street1'].value;and not
theForm.['bill.street1'].value = theForm.['ship.street1'].value;. The extra periods make the format invalid, in the same way usingarray.[2]instead ofarray[2]would invalidate it.