Sunday, 15 January 2012

php - Can't trigger onchange event in page load using JQuery -



php - Can't trigger onchange event in page load using JQuery -

this question has reply here:

show input file dialog on load? 1 reply

currently have link new image next code.

<a class="cmpn_image" href="javascript:void(0);" id="new_page_image">new image</a> /* associated function */ $("#new_page_image").click(function() { imgtype = 'npg'; $("#uptext_new_page").trigger('click'); });

on clicking link, open file upload window.

now need trigger same file input on page load if value nowadays in url. below shown code:

<script> $(document).ready(function() { var param=getparamvalue('p'); // function getting url paramater if(param=='new') { // upto working fine $("#uptext_new_page").trigger('change'); // not working; here if paramter nowadays file upload window should come triggering file input } }); </script> <div style="visibility:hidden;"> <form method="post"> <input type="file" name="name" id="uptext" onchange="ajaxupload(this.form,'imageupload.php?filename=name&amp;maxsize=9999999999&amp;maxw=1000&amp;relpath=uploads/images/&amp;colorr=255&amp;colorg=255&amp;colorb=255&amp;maxh=400','uploadprogress','&lt;br /&gt;&lt;img src=\'images/loader_light_blue.gif\' width=\'128\' height=\'15\' border=\'0\' /&gt;','&lt;img src=\'images/error.gif\' width=\'16\' height=\'16\' border=\'0\' /&gt; error in upload.'); homecoming false;" /> </form> <form method="post"> <input type="file" name="name" id="uptext_new_page" onchange="ajaxupload(this.form,'imageupload.php?filename=name&amp;maxsize=9999999999&amp;maxw=1000&amp;relpath=uploads/reference/&amp;colorr=255&amp;colorg=255&amp;colorb=255&amp;maxh=400','uploadprogress','&lt;br /&gt;&lt;img src=\'images/loader_light_blue.gif\' width=\'128\' height=\'15\' border=\'0\' /&gt;','&lt;img src=\'images/error.gif\' width=\'16\' height=\'16\' border=\'0\' /&gt; error in upload.'); homecoming false;" /> </form> </div>

on page load itself, if parameter p have value new, file upload box should shown. not working.

i tried with

$("#uptext_new_page").change();

can help me prepare this?

thanks in advance.

i don't believe can trigger file input open take file dialog without user interaction. believe if user clicks element, can @ time trigger click event on file dialog, don't think can without user interaction. see:

open file dialog box in javascript click on input box show open file dialog not click on take file button how open file dialog or browse files window using scripts? how open select file dialog via js?

all of these examples showing how trigger file upload window when user clicks on element, not on page load.

same thing goes opening new window javascript (window.open()). if @ random time without user interaction, believe gets caught pop-up blockers. it's similar issue here.

actually, question appears duplicate of show input file dialog on load?, , reply there similar mine (can't without user interaction).

php jquery html file-upload

No comments:

Post a Comment