Jump to content

Recommended Posts

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 by jeff5656
Link to comment
https://forums.phpfreaks.com/topic/279903-insert-html-form-into-javascript/
Share on other sites

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).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.