DeutschEspañolFrançaisItalianoNederlandsPortuguêsΕλληνικάРусскийالعربية中文(简体)中文(繁體)日本語한국어
 
Donate Bitcoins
Google
 
www smithii.com
 

Removing unused query parameters from the URL

I have a web form with several fields. When the user submits the form, they usually only enter data into one of the fields. I wanted the resulting GET url to only include the field(s) they entered any information into. Here's the code I came up with:

<script language='JavaScript' type='text/javascript'>
<!-- // <![CDATA[
function frmSubmit(thiz) {
	var e = thiz.elements;
	for (var i = 0; i < e.length; ++i)
		if (e[i].type == 'text' && e[i].value.length == 0)
			e[i].disabled = true;
	return true;
}
// ]]> -->
</script>
<form method='get' onSubmit='return frmSubmit(this)'>

This appears to work on at least the following browsers:

  • Firefox 1.0.6
  • IE 6.00
  • Opera 8.0

If anyone has a better solution, either client-side, or server-side, I would love to hear it.

DeutschEspañolFrançaisItalianoNederlandsPortuguêsΕλληνικάРусскийالعربية中文(简体)中文(繁體)日本語한국어
 
Donate Bitcoins
Google
 
www smithii.com
 
Special thanks to Riester Rente Online for a generous donation!