Forum Moderators: open
I am just getting started with writing scripts and need a little help...
Somehow I do not know how to get this thing to work and I bet it would be a breeze for one of you guys to give me a hint.
What I want it to do is convert whatever text entered into the textbox to all uppercase and replace things like "$" by "DOLLAR" and "%" by "PERCENT" and so on when the convert button is pressed. I also want it to omit stuff like "^" or ">"...
Well, here it goes:
<html>
<head>
</head>
<BODY>
<td VALIGN=TOP width="100%">
<table border=0 cellpadding=1 cellspacing=4>
<th valign=top BGCOLOR=003399><font face=Verdana,sans-serif size=2 color=FFFFCC>Free Text to Standard-Format Converter</font></th>
<tr><td>
<textarea COLS=69 ROWS=10 type="text" name="convert" value="" maxlength=10
onChange="javascript:this.value=this.value.toUpperCase();" onChange="javascript:this.value=this.value.replace(), "%", "PERCENT")();" onChange="javascript:this.value=this.value.replace(), "$", "DOLLAR")();">
</textarea>
<form name="Converter">
<br>
<input type="button" value="Convert!">
</form>
</BODY>
</html>
Thanks a bunch for your help and best regards,
JP
* only one "onChange" handler is allowed per element;
* "JavaScript:" is redundant inside an event handler
* The textarea doesn't appear to be inside a form;
* You can't use double-quotes in your JavaScript if the script is already enclosed in double-quotes;
* Your brackets are 'messed up' to say the least;
* You might need to 'escape' special characters in the replace();
* ...
This should get you started on the right track:
... onChange="
this.value=this.value.toUpperCase();
this.value=this.value.replace('%', 'PERCENT');
this.value=this.value.replace('$', 'DOLLAR');
" ...