Passing Raw Values Without Any HTML Tags

I’m trying to get the values of some input checkboxes and add them to a add to cart button.

Here is the button code:

<button id="product-addtocart-button" class="button btn-cart" onclick="location.href='<?php echo Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL); ?>checkout/cart/add?product=5&qty=1'">
<span>
<span>
<?php echo $this->__('Add All to Cart') ?>
</span>
</span>
</button>

See where the number “5” is, I need to have this number added dynamically according to the checkboxes that have been checked.

It needs to be like this example: product=5&qty=1 or product=5,27,18&qty=1 i.e. comma separated values.

I’m not sure javascript can do this because everything I’ve found seems like javascript needs some kind of tags to print out in. Like <div id="some-value"></div> or it can add a value to a input field but can it add just a raw value like I need in the button above?

If it can how can I get the value from something like an input field. Like here:

 <input type="checkbox" class="checkbox related-checkbox" id="related-checkbox<?php echo $_product["entity_id"]; ?>" name="related_products[]" value="<?php echo $_product["entity_id"]; ?>" checked>

Here are the problems I’m having with this.

~~ The pre-checked input doesn’t load when the page loads, but one has to click the checkbox first.

~~ Actually I need the checkbox to pass two values. The item id and the item price (added together, goes above the button) but one will be okay for now.

Anyhow, any help on this would be greatly appreciated.

UPDATE:

I found a way to get both values. I found a script that when one checkbox is checked it automatically checks the other checkbox. Then i set one input checkbox to display:none and gave it another class and I now I have two scripts that check each checkbox. All that works good, but the remaining problem is how to get the product id value inside the button add to cart without any additional html tags or script tags.

Here’s the script that gets the product ids:

[code]

[/code]

How do you get the values of the ids without any tags!? Thank you

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.