I have been setting up my plugin in the wordpress admin area. I have a form that stores information from the user. In my file input type, I have javascript function call to my custom javascript that I link to it. This is the line: <li>Category Image:<input type="file" name="category[image]" id="cat_image" onchange="javascript:ImageUpload()" /></li>. however, it returns an error that says undefined function ImageUpload(), surely the function wasn't able to be located. What I was thinking is maybe there is a wordpress function to call for this or is there I need to set up first? But I already link my custom js and it is working. The problem is how to call certain js function from my wordpress php file in the admin area? I hope you guys understand this. Thanks. Here are my codes:
plugin_file.php
<form method="post" name="new_category" id="product_category" enctype="multipart/form-data">
<ul class="add_prod">
<li>Category Title:<input type="text" name="category[title]" id="cat_title" value="" placeholder="Title" /> </li>
<li>Category Description:<textarea rows="4" cols="40" name="category[description]"></textarea></li>
<li>Category Image:<input type="file" name="category[image]" id="cat_image" onchange="javascript:ImageUpload()" /></li>
<li><input type="submit" name="submit" id="submit" value="Submit details" class="btn-submit"/></li>
</ul>
</form>
js file:
function ImageUpload() {
$("#return").show();
$("#return").html('');
$("#return").html('<img src="images/load2.gif" alt="Uploading...."/> wait, uploading...');
$("#imageform").ajaxForm({
target: '#return',
success: function() {
$("#return").fadeOut(10000);
}
}).submit();
}