I have the following piece of code, inside a php script
foreach( $results as $i => $value ){ ?>
<li><form action="getDetail.php" id="detailForm<?= $i ?>" >
<input name="application" value="myTemplate" type="hidden" />
<input name="user" value=<?= $value->publisherID ?> type="hidden" />
<a href="javascript:document.getElementById('detailForm<?= $i ?>').submit();" >
<div class="row" style="padding-left: 10px;"><?= $value->publisherName ?></div>
</a></form></li>
<?php }
it’s working, but I was wondering how I could put this better
remove all form id’s
and put something more generic like
<a href="javascript:$(this).parents('form').submit();" >
which is not working
neither does:
<a href="javascript:$('#detailForm<?= $i ?>').submit();" >
(gives this jquery error-> Uncaught Error: Syntax error, unrecognized expression: );’))
thanks
i think maybe the parents() function returns a list, try doing like this instead: