iChick
07-18-2009, 08:04 PM
Hi!
How can I add this charachter counter to my form? Appreciate any help. :)
<script type="text/javascript">
function CheckFieldLength(go,count)
{var len = go.value.length;if (len)
{go.value = go.value.substring(0);}document.getElementById(count).innerHTML = len;}
</script>
<form>
<input type="text" name="go" id="go" size="64"
onkeyup="CheckFieldLength(go, 'count');" onkeydown="CheckFieldLength(go, 'count');" onmouseout="CheckFieldLength(go, 'count');"/>
<span id="count"></span>
</form>
My Form (it doubles as a Google search box):
<script>
function convert(theForm){
var els = theForm.getElementsByTagName('input');// store inputs
var q = els[0], color = els[1];
if(els[4].checked){// submit to google
theForm.action = 'http://www.google.com/search';
return true;
};
color.value = "You've chosen a "+ q.value +" color";
switch(q.value){// check the query
case 'red':
case 'green':
case 'blue':
location.href = color.value;
return false;
break;
default:
theForm.action="http://www.google.com/search";
break;
};
return true;
};
</script>
<form name= "myform" onsubmit='return convert(this)'> <input name='q' type='text' />
<input name='color' type='hidden' /> <input type='submit' value=" Enter " />
<br />
<input name="searchType" type="radio" value="" checked="checked" > <label for="all"> My Form </label>
<input name="searchType" type="radio" value="google" onclick="document.myform.action='http://www.google.com/search';" />
<label for="google"> Google Search </label></form>
How can I add this charachter counter to my form? Appreciate any help. :)
<script type="text/javascript">
function CheckFieldLength(go,count)
{var len = go.value.length;if (len)
{go.value = go.value.substring(0);}document.getElementById(count).innerHTML = len;}
</script>
<form>
<input type="text" name="go" id="go" size="64"
onkeyup="CheckFieldLength(go, 'count');" onkeydown="CheckFieldLength(go, 'count');" onmouseout="CheckFieldLength(go, 'count');"/>
<span id="count"></span>
</form>
My Form (it doubles as a Google search box):
<script>
function convert(theForm){
var els = theForm.getElementsByTagName('input');// store inputs
var q = els[0], color = els[1];
if(els[4].checked){// submit to google
theForm.action = 'http://www.google.com/search';
return true;
};
color.value = "You've chosen a "+ q.value +" color";
switch(q.value){// check the query
case 'red':
case 'green':
case 'blue':
location.href = color.value;
return false;
break;
default:
theForm.action="http://www.google.com/search";
break;
};
return true;
};
</script>
<form name= "myform" onsubmit='return convert(this)'> <input name='q' type='text' />
<input name='color' type='hidden' /> <input type='submit' value=" Enter " />
<br />
<input name="searchType" type="radio" value="" checked="checked" > <label for="all"> My Form </label>
<input name="searchType" type="radio" value="google" onclick="document.myform.action='http://www.google.com/search';" />
<label for="google"> Google Search </label></form>