简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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