I have a php program which is suppose to alert the links clicked.For example I have a link hello and when I click on that link javascript should alert hello. It works fine without spaces, but when I have a link like hello world it does not alert anything.These words are extracted form a database.
My code is given below
function gmail(val)
{
alert(val);
}
For php
<?php
$name="raj"; //this is just a dummy value
$include "database_connectivity.php";
$conn=odbc_connect($dsn,$database_username,$database_password);
if(!$conn)
{
die('Could not connect to database.'.odbc_error());
}
$select="SELECT WHERE_TO_CHANGE FROM REQUEST_SEND_TABLE WHERE SENT_FROM ='$name'";
$exe=odbc_exec($conn, $select);
if(!$exe)
{
die("Could not execute query".odbc_error());
}
while($row_user=odbc_fetch_array($exe))
{
$show=$row_user['WHERE_TO_CHANGE'];
echo "<input type='hidden' id='".$show."' value='".$show."'>";
echo "<a href='#' id='check' onClick='gmail(".$show.".value)' >".$show." </a>";
echo"<br>";
}
odbc_close($conn);
?>
Can anyone tell me whats wrong here ?
And if
$showcan contain other characters that aren’t allowed in IDs, you’ll need to replace them as well. You’ll also need to escape any quotes when using it in thevalueattribute.