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

您的單選按鈕的鏈接為“ links_xxxx”,xxx為您的php返回的值。 在錨標記中,您需要添加指向自定義函數調用的鏈接。 試試下面

注意我在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