Hey, what i'm trying to do is grab the value of a radio button, compare it to specific values, based on values equaling make four new hidden inputs, which will then be passed to another function. Here is what I have but obviously not working.
//This is supposed to get value from button
function getSelectedRadioValue(buttonGroup) {
// returns the value of the selected radio button or "" if no button is selected
var i = getSelectedRadio(buttonGroup);
if (i == -1) {
return "";
} else {
if (buttonGroup) { // Make sure the button group is an array (not just one button)
//This is probably what is messed up but I want to check if the value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/5x7">http://www.webdeveloper.com/forum/archive/index.php/5x7</a><!-- m --> then
//insert these hidden inputs into the document. Later the function AddtoCart will
//grab these values and pass them to a managecart.html for later checkout.
if buttongroup.value == "5x7"
{
document.write("<input type="hidden" name="PRICE" value="5.00">
document.write("<input type="hidden" name="NAME" value="5x7 - $5.00">
document.write("<input type="hidden" name="ID_NUM" value="0009_5x7">
document.write("<input type="hidden" name="SHIPPING" value="0.00">
}
return buttonGroup.value;
} else { // The button group is just the one button, and it is checked
return buttonGroup.value;
}
}
} // Ends the "getSelectedRadioValue" function
And here is the html calling that:
<input type="button" name="Addtocart" value="Add to cart" onClick="getselectedRadioValue(radio);AddToCart(this.form)">
Thanks a lot for your time.
//This is supposed to get value from button
function getSelectedRadioValue(buttonGroup) {
// returns the value of the selected radio button or "" if no button is selected
var i = getSelectedRadio(buttonGroup);
if (i == -1) {
return "";
} else {
if (buttonGroup) { // Make sure the button group is an array (not just one button)
//This is probably what is messed up but I want to check if the value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/5x7">http://www.webdeveloper.com/forum/archive/index.php/5x7</a><!-- m --> then
//insert these hidden inputs into the document. Later the function AddtoCart will
//grab these values and pass them to a managecart.html for later checkout.
if buttongroup.value == "5x7"
{
document.write("<input type="hidden" name="PRICE" value="5.00">
document.write("<input type="hidden" name="NAME" value="5x7 - $5.00">
document.write("<input type="hidden" name="ID_NUM" value="0009_5x7">
document.write("<input type="hidden" name="SHIPPING" value="0.00">
}
return buttonGroup.value;
} else { // The button group is just the one button, and it is checked
return buttonGroup.value;
}
}
} // Ends the "getSelectedRadioValue" function
And here is the html calling that:
<input type="button" name="Addtocart" value="Add to cart" onClick="getselectedRadioValue(radio);AddToCart(this.form)">
Thanks a lot for your time.