KCfinder, how to pass or send the url variable?
Im sorry if the title is seem confusing :(
I Using KC Finder to develop my CMS file manager
i have HTML code like this
<input type="text" name="url-1" value="" />
<button class="button-primary" onclick="openKCFinder_singleFile(); return false;">Insert</button>
here is the content of openKCFinder_singleFile()
function openKCFinder_singleFile() {
window.KCFinder = {};
window.KCFinder.callBack = function(url) {
window.KCFinder = null;
console.log(url) // URL is the call back result from KCfinder, example: /image/a.jpg
};
window.open('/wp-content/plugins/kcfinder/browse.php', 'kcfinder_single');
}
My Question is, how to set the value input
with the value i get from kcfinder
, as you c开发者_C百科an see we get the value from variable url
, how to pass that to set as input value?
if the code in jQuery script, i really appreciate it :)
Many Thanks
GusDe...
Using jQuery, you can simply add :
$('#url-1').val(url);
See this.
I agree with the answer of user284291, but there is a but :) if you are using this function in a page which does not load jquery, you can send the url by replacing
$('#url-1').val(url);
with
var x = document.getelementbyid('url-1'); x.setAttribute('value', url);
精彩评论