Skip to content Skip to sidebar Skip to footer

Friendly Url With Get Request Form

i have this simple html form:
test/.

If you want them to end up at test/<first_val>/<second_val>/<third_val>/, then you can either use some JavaScript (per pythonFoo's answer), or you can redirect in the view that test/ points to, using HttpResponseRedirect:

deftest_view(request):
  return HttpResponseRedirect('/test/%s/%s/%s/' % request.POST['first'],
                                                  request.POST['second'],
                                                  request.POST['third])

Solution 2:

<inputtype="text"name="first"value=""id="first"><inputtype="text"name="second"value=""id="second"><inputtype="text"name="third"value=""id="third"><p><inputtype="button"value="Continue &rarr;"onclick="submitFriendly();"></p><scripttype="text/javascript">functionsubmitFriendly() {
window.location.href = window.location.href + document.getElementById('first').value + '/' + document.getElementById('second').value + '/' + document.getElementById('third').value;
}
</script>

This should work. It doesn't check if all inputs are filled.

Post a Comment for "Friendly Url With Get Request Form"