Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q913 How can I pass the value of a selected option of a drop-down box from one frame to a text field in another frame without having to press any buttons?

You are here: irt.org | FAQ | JavaScript | Form | 4 | Q913 [ previous next ]

First the frameset:

<frameset rows="50%,*">
<frame src="page1.htm" name="frameNameA">
<frame src="page2.htm" name="frameNameB">
</frameset>

Then in page1.htm:

<form name="myFormName">
<input type="text" name="myFieldName">
</form>

Then in page2.htm:

<form>
<select onChange="parent.frameNameA.document.myFormName.myFieldName.value = this.options[this.selectedIndex].value">
<option value="hello world">option 0
<option value="Hello world">option 1
<option value="Hello World">option 2
<option value="hELLO wORLD">option 3
<option value="HELLO WORLD">option 4
</select>
</form>

To get this to work for a form field on the same page use:

<form name="myFormName">
<input type="text" name="myFieldName">
<br>
<select onChange="document.myFormName.myFieldName.value = this.options[this.selectedIndex].value">
<option value="hello world">option 0
<option value="Hello world">option 1
<option value="Hello World">option 2
<option value="hELLO wORLD">option 3
<option value="HELLO WORLD">option 4
</select>
</form>

Feedback on 'Q913 How can I pass the value of a selected option of a drop-down box from one frame to a text field in another frame without having to press any buttons?'

©2018 Martin Webb