Forum Moderators: open
It works great on the PC and I was about to go live. I tried it on my mac and it didn't work.
Any suggestions or clue? I have the same exact code on a page with customer data and it moves the billing address to shipping with an onclick even on a check box. The only difference here is it a image button.
<script type="text/javascript">
function doIt() {
document.getElementById('size2').value = document.getElementById('size').value;
document.getElementById('opt1').value = document.getElementById('Option1').value;
document.getElementById('opt2').value = document.getElementById('Option2').value;
document.getElementById('opt3').value = document.getElementById('Option3').value;
document.getElementById('persregistry').value = document.getElementById('Presonalize').value;
}
</script>
<input type="image" src="Images/addregistrybutton.gif" border="0" value="Add To Cart" name="registry_1_ATC" onclick="doIt();" alt="Add to Registry" />
The following is untested but based on working code.
function optionsGetValue(optionsId){
var options = document.getElementById(optionsId); if (!options) then return;
var i = options.selectedIndex;
return options.options[i].text;
} Kaled.
I've got a slew of javascript problems revolving around IE, Safari, etc. 3 AM last night. Some forward progress, but not much else. Really could use some advice here.
I built a registry system that uses a separate shopping cart. This creates a second form on each product page.
Each product can have up to 3 drop down values (labels & cost) and there is a field for personalization.
I have successfully found a way to get the labels chosen on the drop downs, but can't get the actual values or the personalization. Here is my doIt statement.. This is supposed to get the size label (it does), then the options value (it does not), and the personalization text field (it doesn't)
Here's code so far...
<script language="Text/JavaScript"> function doIt() {
document.getElementById('size2').value = document.getElementById('size').options[document.getElementById('size').selectedIndex].value;
document.getElementById('opt1').value = document.getElementById('Option1').options[document.getElementById('Option1').selectedtext].value;
document.getElementById('opt2').value = document.getElementById('Option2').options[document.getElementById('Option2').selectedIndex].value;
document.getElementById('opt3').value = document.getElementById('Option3').options[document.getElementById('Option3').selectedIndex].value;
document.getElementById('persregistry').value = document.getElementById('Presonalize').value;
}
</script>
<script language="Text/JavaScript">
The language attribute is deprecated in HTML 4.01, and language="Text/JavaScript" would not have been a useful value anyway. Your previous code (type="text/javascript") was correct.
Also, maybe you should make sure that the script is executed before the form is submitted:
* use
onclick="return doIt();"
return true;as the last line of the function.