This question maybe is little bit strange but I need to learn it asap.
I have a HTML file which is called upgrade.view.php
here is the piece of code that I am on working on:
<form role="form" method="get" action='index.php?action=Frontend_upgradeChosen'>
<div class="col-md-5">
<ul name="S_PRODUCT" id="S_VARIABLE">
<?php
if (isset($oldProduct) && isset($arrayUpgrade)){
foreach ($arrayUpgrade as $value) {
$pro = $value->getnewProduct(); //
echo '<li><a href="index.php?action=Frontend_upgradeChosen" onclick="searchSN(this); return false;">'.$pro->getName().'</a></li>';
}
?>
</ul>
</div>
</form>
</div>
//which closes the main DIV
<script type="text/javascript" language="javascript" src="<?= PATH_VIEWS_INCLUDES_URL ?>js/upgrade/upgrade.js"></script>
On the other hand I am trying to call the JS function from upgrade.js
where I have this function:
function searchSN(elem) {
var a = elem.innerHTML;
alert(a);
}
Finally in my separated PHP file I have this function:
public function upgradeChosen() {
$selectedVariable = $_GET['S_PRODUCT'];
echo 'The Price is:'." ". $selectedVariable;
include $this->getPrintedView();
}
As updated version of the question I am getting the on click event from the <A>
tag but not the value the value of says undefined value.
I have updated the question so that maybe it makes it more understandable what I am trying to achieve.
Many Thanks in Advance
something like this ?
function searchSN(elem) { var a = elem.innerHTML; alert(a); }
<form class="" role="form" method="get" action='index.php?action=Frontend_upgradeChosen'> <div class="col-md-5"> <ul name="S_PRODUCT" id="S_VARIABLE" > <li><a href="index.php?action=Frontend_upgradeChosen" onclick="searchSN(this); return false;">test</a></li> </ul> <button id='choose_product' type="submit" class='btn btn-default'><i class='icon-rocket'>Submit</i></button> </div> </form>
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.