I am not very experienced with Javascript, I am working on a little project on the side and could use some assistance. In essence I am trying to create a form that I can enter key points of data, as well as text, than have it convert to a format in a textbox for easy copy and paste.
<script>
function wordwrap(str, width, brk, cut) {
brk = brk || '\n';
width = width || 60;
cut = cut || false;
if (!str)
return str;
var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' :
'|\\S+?(\\s|$)');
return str.match( RegExp(regex, 'g') ).join(brk);
}
function convert() {
var input = document.getElementById("name").value;
var input = document.getElementById("phone").value;
var input = document.getElementById("sex").value;
var input = document.getElementById("options").value;
var input = document.getElementById("text1").value;
var input = document.getElementById("text2").value;
var input = document.getElementById("text3").value;
input = wordwrap(input, 70, true);
var output = "";
document.getElementById("output").value = output;
}
</script>
<form name="myform" onsubmit="return false;">
Name:<br>
<input type="text" name="name" id="name"><br>
Phone number:<br>
<input type="text" name="phone" id="phone"><br>
Sex?:
<select name="sex" id="sex">
<option value="man">Male</option>
<option value="woman">Female</option>
</select>
<br>
Options:
<select name="Options" id="options">
<option value="opt1">Option 1</option>
<option value="opt2">Option 2</option>
<option value="opt3">Option 3</option>
</select>
<br>
Text 1:<br>
<textarea name="input" id="text1" cols="70" rows="10"></textarea>
<br>
Text 2:<br>
<textarea name="input" id="text2" cols="70" rows="10"></textarea>
<br>
Text 3:<br>
<textarea name="input" id="text3" cols="70" rows="10"></textarea>
<br>
<input type="button" value="Combine" onclick="convert();"><br>
<textarea name="output" id="output" cols="70" rows="10"></textarea>
</form>
I would ideally like to even format how the text appears as such
Name: Entered Name
Phone: Entered number
Sex: Chosen Sex
Option: Chosen Option
Text 1: The text entered
Text 2: The text entered
Text 3: The text entered
I can't seem to get the output to function at all. I would really appreciate any help anyone can offer.