How do I make this onchange thing work?

Bruce Gust
Bruce Gust used Ask the Experts™
My user is given an input field like this:

<input type="text" size="35" name="allocatedmonies" id="allocated_1" onchange="visibility()">

To the immediate right of that field, I want to place a small icon that the user can click on and save the record. I'm thinking that would look something like this:

<div id="save_1" visibility="false"><img src="icon.jpg"></div>

I'm shooting in the dark here, guys, so I'm just giving you scaffolding.

What would be the JavaScript function that would make "save_1's" visibility to be "true" so it would be seen the moment my user alters the data in the "allocatedmonies" field?

What do you think?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Big MontyWeb Ninja at large
if you're using pure javascript, then you would do:

<input type="text" size="35" name="allocatedmonies" id="allocated_1" onchange="document.getElementById(;save_1;).style = 'block';">

of course, you could put the same line in a function called visibility() and just call the function if you want
Similar answer to Big Monty using a seperate function:

function visibility() {
	document.getElementById('save_1').style.visibility = 'visible';
<input type="text" size="35" name="allocatedmonies" id="allocated_1" onchange="visibility()">
<div id="save_1" style="visibility:hidden"><img src="icon.jpg"></div>

Open in new window

Bruce GustPHP Developer


Thanks guys! I have the next challenge / question at, would love it if either one of you would weigh in.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial