It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Use PHP variable in Javascript

Use PHP variable in Javascript

Postby collamack on Wed Nov 10, 2010 9:38 am

Hai, I'm a newbie and I have a big issue. This problem occurred since last year. I copied a javascript from the internet, it's successfully running but it fails me when involve while loop.

Code: Select all
function showFields2<?php echo $rowID['checklist_id'];?>(status) {
var ID = '<?php echo $rowID[checklist_id]?>';
if (status == 0) {
     document.getElementById('checklistlistID').style.display="none";
     } else {                       
     document.getElementById('checklistlistID').style.display="";
     }
}             


Code: Select all
<input class="button" name="checklistEdit" type="button" value="Edit" onClick="showFields2<?php echo $rowChecklist['checklist_id'];?> ('0');" />


Code: Select all
while ($rowChecklist = mysql_fetch_array($resultChecklist))
{
<table width="100%" border="0" cellspacing="2" cellpadding="2" id="checklistlist<?php echo $rowChecklist['checklist_id'];?>">
   <tr>
     <td><?php echo $rowChecklist['checklist_name']; ?></td>
   </tr>
</table>
}


So, I don't know how to make it runs, to differentiate <table id> in while loop & call different javascript function based on ID
collamack
 
Posts: 2
Joined: Wed Nov 10, 2010 9:15 am

Re: Use PHP variable in Javascript

Postby HotNoob on Wed Nov 10, 2010 3:19 pm

lol.

watch your damn php tags

Code: Select all
   
while ($rowChecklist = mysql_fetch_array($resultChecklist))
    {
?>
    <table width="100%" border="0" cellspacing="2" cellpadding="2" id="checklistlist<?php echo $rowChecklist['checklist_id'];?>">
       <tr>
         <td><?php echo $rowChecklist['checklist_name']; ?></td>
       </tr>
    </table>
<?php
    }
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am

Re: Use PHP variable in Javascript

Postby collamack on Thu Nov 11, 2010 2:03 am

OK..Thank you..i missed that part! :? actually, it's a sample coding, I copied some from my full system. But it's failed to run smoothly.

Please help me to settle it... :roll:
collamack
 
Posts: 2
Joined: Wed Nov 10, 2010 9:15 am


Who is online

Users browsing this forum: No registered users and 6 guests