简体   繁体   English

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

[英]how to submit a form through anchor tag such that radio button is also selected?

<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); ?>

your radio buttons have a link of "links_xxxx", xxx being whatever your php is returning. 您的单选按钮的链接为“ links_xxxx”,xxx为您的php返回的值。 in your anchor tag you need to add links to the custom function call. 在锚标记中,您需要添加指向自定义函数调用的链接。 Try the below 试试下面

Note I added 'links_ after customFunction( and closed it off using ' at the end of your php call. 注意我在customFunction(之后添加了'links_,并在您的php调用结束时使用'将其关闭。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM