On Wed, May 15, 2013 at 12:50 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> On Wed, May 15, 2013 at 11:32 AM, Bill Freeman <ke1g...@gmail.com> wrote:
>>> > If there are other values you want to send that are not form inputs, one
>>> > option is to url encode them and add them as query parameters to the
>>> > form
>>> > tag's action attribute, and they will appear in request.GET, even though
>>> > you
>>> > are doing a POST.
>>>
>>> How would I do that? I googled for it, but did not find any examples.
>>
>>
>> See, for example, encodeURI() at
>> http://www.w3schools.com/jsref/jsref_encodeuri.asp
>> If any of your arguments need to contain any of the special characters
>> mentioned as not encoded, encode those arguments first with
>> encodeURIComponent(), linked to from the w3schools article.
>
> Thanks, but I wasn't asking how to encode it, I was asking how to add
> them as query parameters to the form tag's action attribute.

I googled around some more and found that I could do this like this,
for example:

$('#upload').attr('action', "?pixel_size="+$('#pixel_size').val());

That does add pixel_size to the query string, but there are still
issue. I want the form to go to a certain view. In my original form I
had this:

<form id="upload" method="POST" enctype="multipart/form-data"
  action="/report/CDSEM/DR4iBeta/dr4iupload/">

I added a onsubmit function so I could add my parameters to the action
attribute, but that seems to make it ignore the form action. I found
that it was not going the the above view, but instead to
/report/CDSEM/DR4iBeta/. So then I tried to redirect it in the
onsubmit function, but that turned it into a GET and I lost the files.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to