<script>
<!-- hide script from old browsers
function convertCase(conversion, text)
{
var conv, result, i;
for (i=0; i<conversion.length; i++)
{
if (conversion[i].checked)
{
conv = conversion[i].value;
break;
}
}
switch(conv)
{
case 'upper':
result = text.toUpperCase();
break;
case 'lower':
result = text.toLowerCase();
break;
case 'invert':
result = text.replace(/([a-z])|([A-Z])/g, function($0,$1,$2){
return ($1)?$0.toUpperCase():$0.toLowerCase();
});
break;
default:
result = text.replace(/([a-z])|([A-Z])/g, function($0,$1,$2){
return Math.random()>0.5?(($1)?$0.toUpperCase():$0.toLowerCase()):$0;
});
break;
}
window.document.my_tool_form.result.value = result;
return true;
}
// end hiding script from old browsers -->
</script>
</head><body>
<script src="">
</script>
<noscript>
This tool needs JavaScript to work. Please enable it in your browser.
</noscript>
<form name="my_tool_form" action="#">
<table>
<tbody><tr><td><textarea name="text" rows="5" cols="30">Case Converter
Converts case of text either to upper, lower, inverse or random.
Just replace this text with your own, and you can convert it to any case you want.
Happy case converting!</textarea></td></tr>
<tr><td>
<input name="conversion" value="upper" checked="checked" type="radio"> To upper
<input name="conversion" value="lower" type="radio"> To lower
<input name="conversion" value="invert" type="radio"> Invert
<input name="conversion" value="random" type="radio"> Randomize
</td></tr>
<tr><td><input value="Convert" onclick="convertCase(this.form.conversion, this.form.text.value)" type="button"></td></tr>
<tr><td><textarea name="result" rows="5" cols="30" style="border: medium none ;" readonly="readonly"></textarea></td></tr>
</tbody></table>
</form>
</body></html>
javascript - random text
Label: javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment