jquery - django app JavaScript getElementById not working -


i trying post data django app every variable working fine except one..

this form:

<div class="subfield">         <span>         found coupon <b><span style="color:#d95b44;" id="store_name">{{ storedata.0.storename }}</span>?</b>         enter details below share other users         </span>         <form>                                       <br>         <label for="user">coupon code :</label>         <input type="text" id="coupon_code" maxlength="100"  />         <br>         <label for="user">discount :</label>         <textarea rows="2" cols="19" minlength="15" id="coupon_discount"></textarea>         <br>         <div id="buttn">&nbsp;&nbsp;         <button type="button" style="margin:0;padding:0;" onclick="javascript:submitcoupon();">submit coupon</button>         </div>         </form>     </div> 

my javascript is:

<script type="text/javascript">         function submitcoupon()     {            var store_name = document.getelementbyid('store_name').value;         var couponcode = document.getelementbyid('coupon_code').value;         var coupondiscount = document.getelementbyid('coupon_discount').value;         var data =  {"storename":store_name,"couponcode":couponcode,"coupondiscount":coupondiscount,                     csrfmiddlewaretoken:'{{ csrf_token }}'};         alert(store_name);         $.ajax({ // create ajax call...             data: data, // form data             type: "post", // or post             url: "/submit_coupon/", // file call             datatype: "json",             success: function(response) { // on success..              alert("done");              }         });     } </script> 

out of 3 variable couponcode , coupondiscount working not store_name... have tried changing variable name,id nothing working whenever trying alert store_name getting undefined .... , console displaying no error...

<div class="subfield">      <form>          <span>         found coupon <b><span style="color:#d95b44;" id="store_name">{{  storedata.0.storename }}</span>?</b>         enter details below share other users        </span>                                      <br>        <label for="user">coupon code :</label>        <input type="text" id="coupon_code" maxlength="100"  />         <br>        <label for="user">discount :</label>        <textarea rows="2" cols="19" minlength="15" id="coupon_discount"></textarea>          <br>        <div id="buttn">&nbsp;&nbsp;           <button type="button" style="margin:0;padding:0;" onclick="javascript:submitcoupon();">submit coupon</button>        </div>    </form> </div> 

store_name's span used in form run properly


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -