Here's the deal. I've got index.php which links to an internal JS file in it's header. index.php then includes another .php file, which outputs this: + add file. addFile() is a Javascript function defined in the external JS file.
Olur bu şey yaparak, dahil php JS fonksiyonunu "görmez". Dahil PHP JS kapsülleme tüm iş yapar. Ama ben bunu bu şekilde yapmak istemiyorum.
Herhangi bir fikir?
EDIT:
Burada kaynak bulunuyor
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Archie</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="/screen.css" type="text/css" media="screen"/>
<script src="/lib/js/archie.js" type="text/javascript"></script>
</head>
<body>
...
...
//included php starts here
<form action="/lib/course.php" method="post">
<fieldset>
<div id="addFileLocation"></div>
<a href="#" onClick="addFile()">+ add file</a>
<input type="hidden" id="addFileCount" value="0"/>
</fieldset>
</form>
//ends here
...
...
</body>
</html>
ve js:
<script type="text/javascript">
//Dynamically add form fields
//add file browser
function addFile() {
var location = document.getElementById('addFileLocation');
var num = document.getElementById('addFileCount');
var newnum = (document.getElementById('addFileCount').value -1)+ 2;
num.value = newnum;
var newname = 'addFile_'+newnum;
var newelement = document.createElement('input');
newelement.setAttribute('name',newname);
newelement.setAttribute('type','file');
location.appendChild(newelement);
}
</script>