How do I make this onchange thing work?

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?
brucegustPHP DeveloperAsked:
Who is Participating?
John EastonConnect With a Mentor DirectorCommented:
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

Big MontyConnect With a Mentor Senior Web Developer / CEO of Commented:
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
brucegustPHP DeveloperAuthor Commented:
Thanks guys! I have the next challenge / question at, would love it if either one of you would weigh in.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.