javascript - image input type not being detected -
i trying submit form using image input type. ajax request performs fine, , response php script. problem want image button change it's image when submitted (and wasn't doing that). firebug console said form.pic undefined, , image not updated. ideas why?
javascript/jquery
function new_user(form){ var url = "attendance.php"; var datastring = "status="+form.astatus.value; datastring = datastring+"&id="+form.mark_attend.value; $.ajax({ type: "post", url: url, data: datastring, success: function(data) { form.pic.src = data; //error here }, error: function(jqxhr, textstatus, errorthrown){ console.error("error: " + textstatus, errorthrown);} }); return false; }
html
<form method="post" onsubmit="return new_user(this);" > <input type="hidden" value="attended" name="astatus" /> <input type="hidden" value="idkey" name="mark_attend" /> <input type="image" src="greencheck.png" name="pic" /> </form>
$(form).find('input[name="pic"]').attr('src', data);
this, think, cleanest way considering using jquery.
Comments
Post a Comment