<? $sid = md5( uniqid( rand(), true ) ); ?> <form method="post" action="upload.php" id="<?=$sid?>"> <input type="hidden" name="act" value="post"> <input type="file" name="img" value=""> <input type="hidden" name="SUBMIT" value=""> <input type="submit" name="zapisz" value="Zapisz" onClick="ajaxform( '<?=$sid?>', 'ZAPISZ' );"/> </form>
Funkcja do której to idzie:
function ajaxform( nameID, submitvalue, ResponseId ) { if ( document.getElementById(nameID).SUBMIT != "undefined" ) { document.getElementById(nameID).SUBMIT.value = submitvalue; } if( ResponseId == undefined ) { ResponseId = 'contentAJAX'; } if ( arrElement[nameID] != 1 ) { advAJAX.assign(document.getElementById(nameID), { onLoading : function() { contentHTML = document.getElementById( ResponseId ).innerHTML; document.getElementById( ResponseId ).innerHTML = document.getElementById( 'loadtemplate2' ).innerHTML; }, onSuccess : function(obj) { document.getElementById( ResponseId ).innerHTML = obj.responseText; ajaxDebug( obj.responseText ); }, onError : function(obj) { document.getElementById( ResponseId ).innerHTML = contentHTML; window.alert('Wystąpił nieoczekiwany błąd. Powtórz operację.'); } }); } if (document.getElementById(nameID) != "null" ) { arrElement[nameID] = 1; } return false; }