javascript - Extract from JS to url -
but interested in how can send result js get
<form method="get" action="order2.php"> <input type="checkbox" name="obj" price="5" value="1" >5 <input type="checkbox" name="obj" price="15" value="2">15 <input type="checkbox" name="obj" price="20" value="3">20 <input type="submit" value="send"> <div id="test"></div> <script type="text/javascript"> $(":input").change(function() { var values = $('input:checked').map(function () { return $(this).attr('price');; }).get(); var total = 0; $.each(values,function() { total += parsefloat(this); }); $("#test").text(total); }); </script> </form>
when select inputs 1 , 2 result in url order2.php?price=20
$(":input").change(function() { var values = $('input:checked').map(function () { return $(this).attr('price');; }).get(); var total = 0; $.each(values,function() { total += parsefloat(this); }); $("#test").text(total); $('form').attr('action', 'order2.php?price=' + total); console.log ( $('form').attr('action') ) ; });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> interested in how can send result js when select inputs 1 , 2 result in url order2.php?price=20 <form method="get" action="order2.php"> <input type="checkbox" name="obj" price="5" value="1" >5 <input type="checkbox" name="obj" price="15" value="2">15 <input type="checkbox" name="obj" price="20" value="3">20 <input type="submit" value="send"> <div id="test"></div> </form>
Comments
Post a Comment