javascript - Form Input: Get Unique Value With Same Name & ID -
below result query posted address page. accomplished using php called ajax.
<div id="address-wrap"> <div id="report-address">3719 cocoplum cir <br> unit: 3548<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64638716"> <input name="submit" type="submit" value="view report"> </form> </div> <div id="clear"></div> </div> <div id="address-wrap"> <div id="report-address">3927 cocoplum cir <br> unit: 35124<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64638744"> <input name="submit" type="submit" value="view report"> </form> </div> <div id="clear"></div> </div> <div id="address-wrap"> <div id="report-address">3949a cocoplum cir <br> unit: a<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64639105"> <input name="submit" type="submit" value="view report"> </form> </div> <div id="clear"></div> </div> <div id="address-wrap"> <div id="report-address">3949 cocoplum cir <br> unit: 3602<br> pompano beach, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64639106"> <input name="submit" type="submit" value="view report"> </form> </div> <div id="clear"></div> </div> <div id="address-wrap"> <div id="report-address">3949 cocoplum cir <br> unit: 3603<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64639107"> <input name="submit" type="submit" value="view report"> </form>
below request on report page. need value form , pass reports page can append ajax request.
<script type="text/javascript"> var property-id = $('.property-id').val(); $.ajax({ url: 'http://www.domain.com/php/reports.php', data: '?recordid=' + property-id, success: function(data){ $('#results').html(data); } }); </script>
my main issue don't value form clicked on. give me first value in list 64638716. how can append proper values
thank in advance
try out. there few errors in javascript, variables names contained hyphen property-id
changed propertyid
, dont forget modify in code
$(document).ready(function(e) { $("input[type=submit]").click(function(e) { var propertyid = $(this).prevall("input").first().val(); //alert(propertyid); $.ajax({ url: 'http://www.domain.com/php/reports.php', data: '?recordid=' + propertyid, success: function(data){ $('#results').html(data); } }); e.preventdefault() return false; // prevent form submitting }); });
Comments
Post a Comment