php - Only submit this.val on form when submitted? -
php - Only submit this.val on form when submitted? -
i'm making form displays dynamic value , have forms action in jquery function , want take value out of $(this).closest('tr') <input type="text" class="line_order_id" value="'.$order_id.'" size="5" readonly>
want take value .line_order_id
, send php page process.
jquery
$(document).ready(function(e) { $('.viewthis').live({ click: function() { var $tr = $(this).closest('tr'); var order_id = $('.line_order_id', $tr).val(); $('form#orderslist').attr({ action: "phpdump.php", target: "_blank", }).submit(); homecoming false; } }); });
any ideas??
given existing code seems value input in question , set in order_id
variable, question how set value form , submit it?
if so, think 2 obvious ways set in hidden input field or add together query string parameter.
add form:
<input type="hidden" id="hiddenorderid" name="orderid" />
(use whatever name
want - that's name of parameter you'll process in php.)
then in function before existing .submit()
add:
$("#hiddenorderid").val(order_id);
(you create hidden input dynamically , set value, since seem targeting blank window can presumably submit multiple times , case think creating single hidden input straight in html markup lot less problem worrying creating 1 dynamically first submit , reusing subsequent submits.)
edit: pass value in query string:
$('form#orderslist').attr({ action: "phpdump.php?orderid=" + encodeuricomponent(order_id), target: "_blank", }).submit();
you can omit .encodeuricomponent
if know id plain number, user-input info have allow characters have special meaning in uri.
php jquery
Comments
Post a Comment