0 Members and 1 Guest are viewing this topic.
<!DOCTYPE html><head><script language="javascript" type="text/javascript">function addtext() { var newtext = document.myform.inputtext.value; document.myform.outputtext.value += newtext;}</script></head><body><form name="myform"><input type="inputtext" size="25" /><input type ="outputtext" size = 25" /><p></p><input type="button" value="Convert" onClick="addtext();"></form></body></html>
<input type="inputtext" size="25" /><input type ="outputtext" size = 25" />
<input type="text" name="inputtext" size="25" /><input type="text" name="outputtext" size = 25" />
function addtext() { var newtext = document.forms['myform'].elements['inputtext'].value document.forms['myform'].elements['outputtext'].value += newtext;}
Yep, I see it:Code: [Select]<input type="inputtext" size="25" /><input type ="outputtext" size = 25" />should beCode: [Select]<input type="text" name="inputtext" size="25" /><input type="text" name="outputtext" size = 25" />
TryCode: (Javascript) [Select]function addtext() { var newtext = document.forms['myform'].elements['inputtext'].value document.forms['myform'].elements['outputtext'].value += newtext;}instead.
<input type="text" name="inputtext" size="25" /><input type="text" name="outputtext" size="25" />
Also, shouldn't:Code: [Select]<input type="text" name="inputtext" size="25" /><input type="text" name="outputtext" size = 25" />be written as:Code: [Select]<input type="text" name="inputtext" size="25" /><input type="text" name="outputtext" size="25" />
there is a slight difference but does it matter if there are spaces in between the equals sign. i guess it is better coding to have them consistent, either have spaces or don't have spaces.<input type="text" name="outputtext" size = 25" />
YOUR_STRING_HERE.replace(/\s/g, '');/ denotes the start (and end) of a regex expression, \s matches all whitespace, and /g ends the regex and tells it to replace every match (instead of just the first one).
inputText = inputText.replace(/[^A-Fa-f0-9]+/g,'').replace(/(\r\n|\n|\r)/gm,"").toUpperCase();
\s captures all linebreaks, tabs, spaces, etc. It's the same as [\r\n \t ... ].You don't need to do \r\n|\n|\r. That's the same as [\r\n], which is included in \s.