Mounica Yelchuri Mounica Yelchuri - 9 months ago 31
PHP Question

how to take computed values into javascript

<h1>Job posts</h1>
<?php foreach ($company as $com){?>
<h1><?php echo $com[0];?>'s Profile</h1><?php ?>
<h4>Job Details</h4>
<p>Designation: <?php echo $com[1];?></p>
<p>package: <?php echo $com[2];?></p>
<p>Posting Location: <?php echo $com[3];?></p>
<p>Test date: <?php echo $com[4];?></p>
<h4>Student Requirements</h4>
<p>Branch: <?php echo $com[5];?></p>
<p>CGPA: <?php echo $com[6];?></p>
<p>Twelfth Percentage: <?php echo $com[7];?></p>
<p>Tenth Percentage: <?php echo $com[8];?></p>
<p>Year Of Passing: <?php echo $com[9];?></p>
<p>Number of Backlogs allowed: <?php echo $com[10];?></p>
while ($row= mysqli_fetch_assoc($comp_data)){
foreach($students as $s)
echo "student is eligible";
<form >
<input type="button" value="apply now" onclick="msg()">
<?php }
echo "not eligible";

function msg() {
var check="<?php echo $email?>";

<?php }?>

this code first displays job posts available and checks students eligible for that particular company and also checks whether particular student is eligible or not.. now task remaining is when student clicks on apply now button of company and email should be passed to msg() function. how can i do this?


You can pass the email and company name into msg() by including parameters in the function call.

The Button

I don't know which index in $com contains the company's name. You may need to adjust the index in $com[0] as used below.

<input type="button" value="apply now" onclick="msg('<?= $email ?>', '<?= $com[0]?>')">

The JavaScript

    function msg(email, companyName) {
        var check = "<?php echo $email?>";

        //do something with email

        //do something with companyName