Link to home
Start Free TrialLog in
Avatar of freshgrill

asked on

Remove empty post variables with no value

Want to remove empty post variables with no value, need to update windows  URL with shorten version.

Prefer lightest method, can use jquery but would like an answer without any library if possible
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

What are you talking about?
Avatar of freshgrill


Sorry, it should be Get method. When a user submits a form using the get method, we want to remove all the empty variables and have the url show only the variables that have values (were selected).
Avatar of leakim971
Flag of Guadeloupe image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For a jQuery version

	$('input,select', this).each(function(){
		if($(this).val() == "") $(this).remove();

Open in new window

I like leakim's idea of just removing the name attribute!