As a Javascript Noob I'm having a bit of problem writing some javascript that will dynamically update the 'action' of a form when the form is submitted.

Its for an Image Upload script which performs a binary read on the uploaded image, meaning I have to POST the form, but must pass any additional parameters to the Image Upload script via the querystring.

Actually, you only want the image POSTed, right? Because the way it's set up now, since the caption input is part of the form and has a name attribute, the caption will be POSTed along with the image, as well as submitted via the query string because of the JavaScript.

So you should probably get rid of the name attribute in the caption input, since name attributes are only needed to tell the browser to send that information along to the server-side script specified in the form tag's action attribute. That way, the caption will only be sent in the query string and not in the POST.

SortedSites
—
2011-07-10T20:12:27Z —
#5

bhawk90 said:

Yeah, that's what I meant.

Actually, you only want the image POSTed, right? Because the way it's set up now, since the caption input is part of the form and has a name attribute, the caption will be POSTed along with the image, as well as submitted via the query string because of the JavaScript.

So you should probably get rid of the name attribute in the caption input, since name attributes are only needed to tell the browser to send that information along to the server-side script specified in the form tag's action attribute. That way, the caption will only be sent in the query string and not in the POST.

Thanks will give it a try.

SortedSites
—
2011-07-11T14:34:42Z —
#6

bhawk90 said:

Yeah, that's what I meant.

Actually, you only want the image POSTed, right? Because the way it's set up now, since the caption input is part of the form and has a name attribute, the caption will be POSTed along with the image, as well as submitted via the query string because of the JavaScript.

So you should probably get rid of the name attribute in the caption input, since name attributes are only needed to tell the browser to send that information along to the server-side script specified in the form tag's action attribute. That way, the caption will only be sent in the query string and not in the POST.

You seem to have understood what I want really well, but sadly I'm still having a problem:

But the caption value is still not appended to the the querystring of image-upload.asp after the form is submitted.

bhawk90
—
2011-07-11T18:56:43Z —
#7

If the code you've provided for the submitform() function is a copy and paste from your code, then you're missing an 'n' in the word Element in the call to document.getElementById() that accesses the caption, and the 'D' in 'ID' should be a 'd'.

SortedSites
—
2011-07-11T22:15:16Z —
#8

bhawk90 said:

If the code you've provided for the submitform() function is a copy and paste from your code, then you're missing an 'n' in the word Element in the call to document.getElementById() that accesses the caption, and the 'D' in 'ID' should be a 'd'.

Yeah sorry I copy-pasted my mis-spelled code from my prev forum post but the actual code I have is: