JS not executing
i have this code:
if ($has_freechat1 && $has_freechat2)
{
if (($has_freechat1['confirmed'] == 1) && ($has_freechat2['confirmed'] == 1))
{
$was_clicked = 0;
?>
<a href="freechatcontacts.php?id=<?php echo $id_to.$was_clicked; ?>" class="charcoal_link" style="line-height: 20px;" name="message" id="message" onClick="return send('<?php echo $was_clicked;?> return false;')">
<?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?>
</a>
&开发者_StackOverflow社区;nbsp;
<?php
if ($was_clicked == 1)
{
?>
<tr>
<td><input name="password" type="textarea" rows="10" cols="20" value="<?php echo $aCleanPost['message']['value']?>" /></td>
</tr>
<tr>
<td><br /><input name="cmdSubmit" type="submit" value="Send" /><br/> </td>
</tr>
<?php
}
}
the above displays a uniquecode link, when i click on it i want an html textarea to display so user can type in a short message..the onlcick send() is a JS function but it does not execute it so i can set $was_clicked to 1
how can i get round this problem? please help thank you
Edit
sendMessage
function from comments:
<script type="text/JavaScript">
function send(val)
{
val = 1; //was clicked
return val;
}
</script>
Your onclick handler must call a javascript function, not a php function.
Your code syntax seems wrong.
onClick="return send('<?php echo $was_clicked;?> return false;')">
Try
onClick="javascript:send('<?php echo $was_clicked;?>'); return false;">
精彩评论