Passing variables from PHP to JavaScript
Posted: Mon Apr 19, 2004 9:59 am
Hi guys,
Can anyone help me with this:
I have a php file called a.php with the following code:
[Edit: Added PHP tags for eyecandy. --JAM]
when I click on delete button, I dont get the name of the form in the alert box, I dont know what's wrong with my code.
thanks in advance.
Can anyone help me with this:
I have a php file called a.php with the following code:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN"-->
<?php require"../../config.php"?>
<html>
<head>
<script language="JavaScript">
function formSubmit()
{
var formName="<?echo($form_name);?>";
alert(formName);
}
</script>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#333366">
<tr>
<td width='100'>first name</td>
<td width='100'>last name</td>
<td width='100'>Options</td>
</tr>
<? displayUsers() ?>
</table>
</body>
</html>
<? function displayUsers()
{
for($i=0;$i<2;$i++)
{
$form_name="form".$i;
$fname="A".$i;
$lname="B".$i;
echo" <tr>
<td> $fname</td>
<td> $lname</td>
<td>
<form name=$form_name>
<input type='button' value='Delete' onClick='formSubmit();'>
</form>
</td>
</tr>";
}
}
?>when I click on delete button, I dont get the name of the form in the alert box, I dont know what's wrong with my code.
thanks in advance.