63
rated 0 times
[
67]
[
4]
/ answers: 1 / hits: 34936
/ 11 Years ago, thu, august 8, 2013, 12:00:00
I currently have a table that has a list of email template names being echoed using php. Below is part of the php code. I'm trying to grab the table value and pass it to my JS file where a future AJAX command will pass it to a different file (that I won't have any issues with). My first attempt to alert out the value stated that the value was undefined. My second attempt showed the type of element it was inside (at the time it was a span). Now it's not showing anything. Suggestions?
PHP code:
<table class=departments>
<tr>
<th scope=col style=width: 175px;>Email Name</th>
';
$get_depts = mysql_query(SELECT dept_name FROM depts where bus_id = '{$_SESSION['bus_id']}');
while(($department = mysql_fetch_assoc($get_depts)))
{
echo '
<th scope=col style=width: 175px;>'.$department['dept_name'].'</th>
';
}
echo '
</tr>
';
$get_emails = mysql_query(SELECT id, email_name from emails where bus_id = '{$_SESSION['bus_id']}' ORDER BY email_name ASC);
while(($email = mysql_fetch_assoc($get_emails)))
{
echo '
<tr>
<td id=test onclick=moveValue()>'.$email['email_name'].'</td>
';
Current JS code:
function moveValue()
{
var x = document.getElementById(test);
var y = x.innerHTML;
alert(y);
}
More From » onclick