如何通过锚标记提交表单,以便选择单选按钮?

时间:2011-04-15 11:59:48

标签: php javascript magento

<script language="javascript">

function customFunction(url){

alert(url);

//window.location = "url";

//document.all.url.checked = true;

document.getElementById('url').checked = true;

document.downloadable_prod.submit();
}
</script>

<!-- Note : this below radio buttons coming from loop --->

<input type="radio" name="links" id="links_<?php echo $_link->getId() ?>" value="<?php echo $_link->getId() ?>" />

<a href="javascript:customFunction(<?php echo $_link->getId() ?>);" class="buy_stan">

<span style="margin-left:160px;">

   <?php echo $this->getFormattedLinkPrice($_link); ?>

1 个答案:

答案 0 :(得分:0)

你的单选按钮有一个链接“links_xxxx”,xxx就是你的php返回的内容。在您的锚标记中,您需要添加自定义函数调用的链接。试试下面的

注意我在customFunction之后添加了'links_(并在你的php调用结束时使用'关闭它。

<a href="javascript:customFunction('links_<?php echo $_link->getId() ?>');" class="buy_stan">