mrpeenut24
September 15th, 2007, 07:21 PM
I'm writing a simple conversion tool using html/js and don't currently have too much experience in javascript. I'm using a form with textboxes and a submit button to initiate the conversion, however, when I push the submit button, the form's GET essentially sends me to a new page and erased the info set by the javascript. Here's what I'm talking about:
<form>
<textarea style="background-color: lightyellow;" name="conversion"></textarea>
<br>
Convert from
<select name="convertFrom">
<option value="text">Text</option>
<option value="hex">Hex</option>
<option value="binary">Binary</option>
</select>
to
<select name="convertTo">
<option value="text">Text</option>
<option value="hex">Hex</option>
<option value="binary">Binary</option>
</select>
<br>
<textarea style="background-color: pink;" name="converted"></textarea>
<br>
<button onclick="action1(conversion, convertFrom, convertTo, converted);">Convert</button>
<br>
</form>
This writes the converted data to the second textarea using
converted.value=convertedData;This writes it to the text area, but as soon as it does, the page is redirected with the GET method and all the data is erased. Is there some postback-ish way I should be doing this?
Thanks.
<form>
<textarea style="background-color: lightyellow;" name="conversion"></textarea>
<br>
Convert from
<select name="convertFrom">
<option value="text">Text</option>
<option value="hex">Hex</option>
<option value="binary">Binary</option>
</select>
to
<select name="convertTo">
<option value="text">Text</option>
<option value="hex">Hex</option>
<option value="binary">Binary</option>
</select>
<br>
<textarea style="background-color: pink;" name="converted"></textarea>
<br>
<button onclick="action1(conversion, convertFrom, convertTo, converted);">Convert</button>
<br>
</form>
This writes the converted data to the second textarea using
converted.value=convertedData;This writes it to the text area, but as soon as it does, the page is redirected with the GET method and all the data is erased. Is there some postback-ish way I should be doing this?
Thanks.