django - Submit form with input added in the URL and not as parameter -


supposing have following form. there better way send value of input in url in example "indication_effects/+my_value" , rid of parameter indication=my_value??

maybe possible django or should use django form?

thank you,

          <form id="indication-form" class="form-horizontal" method="get">             <div class="form-inline">                 <div class="col-md-8">                     <input type="text" class="form-control" id="indication-input" name="indication" />                      <button class="btn btn-primary" type="submit" id="indication-submit">submit</button>                 </div>             </div>         </form>  var indicationform = $('#indication-form');  $("#indication-submit").on("click", function () {     indicationform.attr("action", "indication_effects/" + $("#indication-input").val());     indicationform.submit(); }); 

look, get request always send form data through url , post request always send form data through request headers.

it may not pretty, it's way works.

however, can nice vue.js want.

disregard form action, change submit button <button> <a> , build href dynamically, can "submit" form using form data on html.

something this:

<div id="app">     <form id="indication-form" class="form-horizontal" method="post" action=".">         <div class="form-inline">             <div class="col-md-8">                 <input type="text" class="form-control" id="indication-input" name="indication" v-model="indication" />                  <a :href="geturl" class="btn btn-primary" id="indication-submit">submit</a>             </div>         </div>     </form> </div>  <script src="//unpkg.com/vue"></script> <script type="text/javascript">     new vue({         el: '#app',         data: {             indication: '' // link form fields v-model here         },         computed: {             geturl: function() {                 return '/' + this.indication + '/'; // build url             }         }     }); </script> 

vue.js powerful , simple javascript framework, much.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -