Display value on the same page.html

Hello Everyone,

How could I display the selected value on the page instead of displaying it on a textarea box ?
Thanks in advance

<script language="JavaScript"><!--
function onClick() {
  var Current =
    document.formName4.selectName4.selectedIndex;
    document.formName4.currentText4.value =
    document.formName4.selectName4.options[Current].text;
}
//--></script>

<form  name="formName4" onSubmit="return false;">
<select  name="selectName4">
<option  id="Option 0">Entry 0
<option  id="Option 1">Entry 1
</select>
<input type="submit"  onClick="onClick();return false;">
<br>
<textarea id="currentText4"></textarea>
</form>

You can create <div> and place your text inside of it dynamically.

HTML:

<div id="my-message"></div>

JS:

document.getElementById("my-message").innerHTML = document.formName4.selectName4.options[Current].text;

Thank you so much Megazoid, it does work :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.