jeff5656 Posted July 5, 2013 Share Posted July 5, 2013 (edited) Hi, I know very little about javascript. the following script echos out column width after a user drags the columns of a table. I would like to capture the output into a form, so the user can submit it to their record and system will remember settings if they reload the screen: $(function(){ var onSampleResized = function(e){ var columns = $(e.currentTarget).find("th"); var msg = "columns widths: "; columns.each(function(){ msg += $(this).width() + "px; "; }) $("#sample2Txt").html(msg); }; Now this line: columns.each(function(){ msg += $(this).width() + "px; "; }) seems to echo out the widths of each column (the display says something like: "Column widths: 112px; 256px; 320px; 15px") How can I have each value get echoed into a separate input box (type=text)? Then when user submits the form, I will use php to process form and get the values into a database. Edited July 5, 2013 by jeff5656 Quote Link to comment https://forums.phpfreaks.com/topic/279903-insert-html-form-into-javascript/ Share on other sites More sharing options...
Irate Posted July 6, 2013 Share Posted July 6, 2013 You can use <input type="hidden" id="my_Id" value="" name="width_input"> in your HTML page and change $('#sample2Txt').html(msg) to $('#my_Id').attr('value',msg) or something like that and then you simply query the $_POST['width_input'] your PHP script (but do guard against cases where JavaScript has been disabled by the client by checking the value of $_POST['width_input'] in your PHP script (above suggestions are based on the assumption that you are using a POST request). Quote Link to comment https://forums.phpfreaks.com/topic/279903-insert-html-form-into-javascript/#findComment-1439588 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.