[Answer]-How do I create pretty url from the GET parameters in Django?

1๐Ÿ‘

โœ…

<script>
function changeAction() {

var profile_form = document.getElementById('profileform');
        if(profile_form) {
        var txt = "http://www.example.com/";
        var i;
        for (i = 0; i < profile_form.length; i++) {
            txt = txt + profile_form.elements[i].value + "/";
        }
           profile_form.action = txt; 
        }}
</script>

And in your html, you need something like this:

<form action="" method="get" id="profileForm" onsubmit="changeAction()">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  Place <input type="text" name="place"><br>
  <input type="submit" value="Submit">
</form>

I guess this should do the trick.

๐Ÿ‘คAnimesh Sharma

Leave a comment