Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide button works but when changed to image doesn't 1

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey there,

I have a page that has the submit button hidden until a selection is made.

It works perfectly.

However when I then change the button to be an image i.e. from

Code:
<input type='submit' value='Next' name='nextbutton' id="nextbutton"  style='visibility:hidden' >
to
Code:
<input type='image' src="/images/buttonnext.gif" value='Next' name='nextbutton' id="nextbutton"  style='visibility:hidden' >

it breaks and return a javascript error "nextbutton is not defined".

Any clues on what I am doing wrong or is this just not possible?


Steve
- I have fun with telemarketers
 
here's the code that triggers the button to appear -
Code:
<div class='centeredradio'>
				<input name='templateID' type='radio' value='<?php echo  $row_templates["templateID"]; ?>' onclick='nextbutton.style.visibility="visible";resetbutton.style.visibility="visible"'> 

			</div>
it is then hidden again by clicking the reset button in the code in the original post.

As I said, it works perfectly if I use the generic form buttons. The problem happens when I change the button to display an image instead.

Steve
- I have fun with telemarketers
 
Where is "nextbutton" defined? You must be testing in IE, as it lets users get away with this sort of non-standard DOM play.

Instead of assuming you can access "nextbutton" just by referencing it, you should use:

Code:
document.getElementById('nextbutton')

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top