Reputation: 125
I have a select as below. Below it I got a link where current the eID value I fixed to a session value. What I would require is to change it dynamically when I select the eID value. I know in my getMList function I can get the value but how to update this portion of the codes window.open('addAdSelect.php?eID=' such that the select eID is updated accordingly.
<select class='select' id='eID' name='eID' onchange='getMList(this.value)'>
</select>
<tr>
<td>
</td>
<td>
<a href='#' onclick="window.open('addAdSelect.php?eID=<?php echo $_SESSION['eID']; ?>', 'ADS','width=500, height=750,scrollbars=yes')">Select List</a>
</td>
</tr>
Upvotes: 1
Views: 464
Reputation: 193261
I would go with this approach. Change link HTML to this one:
<a href="#" id="link" data-eid="<?php echo $_SESSION['eID']; ?>"
onclick="window.open('addAdSelect.php?eID=' + this.getAttribute('data-eid'), 'ADS','width=500, height=750,scrollbars=yes')">Select List</a>
Then in change getMList
to update link data-eid
attribute:
function getMList(eid) {
document.getElementById('link').setAttribute('data-eid', eid);
// ...
}
So the idea is that on select onchange
event you update data-eid
attribute of the link.
Upvotes: 1