In the current example I have a form set up that takes a unique id. There is also a link that takes a unique id. The javascript function will fade in that form when the link is selected. Is it possible to call a javascript function based on the PHP variables used to id the form and the link? And so that it will fade in the correct when that corresponds to the unique id of the form?
PHP
while($row = mysql_fetch_array($query)){ $form_id = $row[id]; ?><a href="#"
id="askedClick"><?php echo $row[post_text].'<br>'?></a>
<form action="<?php $curent_file ?>"
method="POST" id="<?php echo $row[id] ?>">Do you know the anwer?
<input type="submit" value="Yes" name="<?php echo $form_id.'yes'?>"
/>
<input type="submit" value="No" name="<?php echo $form_id.'no'?>" />
</form>
<?php } ?>
JAVASCRIPT
$(document).ready(function () {
$("phpvariable").hide();
$("#phpvariable").click(function () {
$("#phpvariable").fadeIn(1200)
});
});
You could use ids, but it will be much easier to just give your link a class of say “showForm” and use HTML traversal to hide the form that follows it