I want "s.value" to be turned all to lowercase and then ucwords to it but I don't know how to do it since it's inside a form.
Basically I want to do something like this: ucwords(strtolower( s.value here ));
This is the form:
<form role="search" method="get" id="searchform" action="http://chusmix.com/?s=" onsubmit="if (document.getElementById('s2').value.length > 5) window.location = action + '<php echo $city; ?>++++' + s.value; return false;" >
Thanks
The ucwords() function converts the first character of each word in a string to uppercase. Note: This function is binary-safe. Related functions: ucfirst() - converts the first character of a string to uppercase. lcfirst() - converts the first character of a string to lowercase.
The strtoupper() function converts a string to uppercase.
The ucfirst() function converts the first character of a string to uppercase. Related functions: lcfirst() - converts the first character of a string to lowercase. ucwords() - converts the first character of each word in a string to uppercase.
<script type="text/javascript">
function ucwords (str) {
return (str + '').replace(/^([a-z])|\s+([a-z])/g, function ($1) {
return $1.toUpperCase();
});
}
function strtolower (str) {
return (str+'').toLowerCase();
}
</script>
<form role="search" method="get" id="searchform" action="http://chusmix.com/?s=" onsubmit="if (document.getElementById('s2').value.length > 5) window.location = action + '<?php echo $city; ?>++++' + ucwords(strtolower(s.value)); return false;" >
The javascript functions are from PHP.JS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With