jquery uploadify -
i want upload multiple file title , link. getting following error
invalid property id
$('#divupload').uploadifysettings('scriptdata',{,'txttitle1':'title1','tbxlink1':'link1','1':'image1.png'},'1');
my code :
<script type="text/javascript" language="javascript"> var divmsg ='<%= divmsg.clientid %>'; var errcnt=0; $(document).ready(function() { $('#divupload').uploadify({ 'uploader': websiteurl + 'admin/fileupload/uploadify.swf', 'script': websiteurl + 'admin/banner-image-upload.aspx?type=fileupload', 'multi' : 'true', 'method' : 'post', 'cancelimg' : websiteurl + 'admin/images/cancel.png', 'folder': '../source/bannerimage', 'queuesizelimit' : '20', 'filedesc' : '*.jpeg;*.jpg;*.gif;*.png;*.bmp', 'fileext': '*.jpeg;*.jpg;*.gif;*.png;*.bmp', 'wmode' : 'transparent', 'oncancel':function(event,queueid,fileobj,data){if(data['filecount']==0){txtboxindex=0;$('#btnuploadfile').hide();}else{txtboxindex=txtboxindex-1;}}, 'onallcomplete': function(event,data) { if(errcnt==0) { window.opener.location.href =websiteurl + 'admin/home-banner-list.aspx?mode=uploadsucc'; window.close(); } }, 'onselect' : function(event,queueid,fileobj){$('#btnuploadfile').show();}, 'oncomplete': function(event,queueid,fileobj,response,data){if(response=='maxupload')errcnt++;}}) }); function uploadfiles() { var cnt=''; var str=''; var strlink=''; $('.txttitle').each(function(index){ if(jquery.trim($(this).val())=='') { if(cnt.length ==0) cnt=(index + 1); else cnt=cnt + ',' +(index + 1); } }); if(cnt.length!=0) { alert('please insert title in photo#' + cnt); return false; } $('.txttitle').each(function(index){ cnt= $(this).attr('name').replace('txttitle',''); str =str + ',\'' + $(this).attr('name') + '\':\'' + $(this).val() + '\''; str =str + ',\'' + $('.tbxlink').attr('name') + '\':\'' + $('.tbxlink').val() + '\''; str= str + ',\'' + cnt + '\':\'' + $('#hdnfile'+ cnt).val() + '\''; }); str='{' + str + '}'; alert(str); eval('$(\'#divupload\').uploadifysettings(\'scriptdata\',' + str +');'); $('#divupload').uploadifyupload(); } </script>
you're generating invalid code, this:
$('#divupload').uploadifysettings('scriptdata',{,'txttitle1':'title1','tbxlink1':'link1','1':'image1.png'},'1'); ^ invalid comma
but...it's better not use eval()
@ all, can construct data object bracket notation, this:
var data = {}; $('.txttitle').each(function() { data[this.name] = this.value; data[$('.tbxlink').attr('name')] = $('.tbxlink').val(); data[cnt] = $('#hdnfile'+ this.name.replace('txttitle','')).val(); }); $('#divupload').uploadifysettings('scriptdata',data);
granted that's literal translation of you're trying do...this still isn't optimal, $('.tbxlink').attr('name')
line, since you're wanting .tbxlink
relates this .txttitle
element you're on, without seeing markup can't should like.
Comments
Post a Comment