Click to See Complete Forum and Search --> : changing button value
neil9999
08-27-2003, 10:47 AM
Hi,
I'm trying to make a button that when you click on it, if the button's value is 'Next' it changes to 'Enter'. The default value is 'Next'. When you click on it it calls up the function 'next()'. What is wrong with the code bellow?
<script language=javascript>
function next(){
if(document.getElementById('next').Next){document.getElementById('next').value='Enter'};
}
</script>
Thanks,
Neil
Khalid Ali
08-27-2003, 11:24 AM
here use the following
if(document.getElementById('next').value=="Next"){
document.getElementById('next').value='Enter';
};
gcrowan
08-27-2003, 12:36 PM
If you are submitting a form, you might also want to consider:
<head>
<title>Untitled</title>
<script>
<!--
function next(e,f){
if(e.innerText=='Next'){
e.innerText = "Enter";
f.submit();e.disabled=true;
}else{
return false;
}
}
//-->
</script>
</head>
<body>
<form action="something.html" method="post">
<button value="Next" type="submit" onclick="next(this,this.form)">Next</button>
</form>
</body>
</html>
Khalid Ali
08-27-2003, 12:57 PM
innerText is an IE specifc property,Id say keep away from it if you want your page to work in most browsers to say the least.
gcrowan
08-27-2003, 06:59 PM
you can use input.value in place of input.innerText if you need to be browser friendly. I spent many years going out of my way to write for both IE and Netscape but have found Netscape to by a waste of my time. Sorry If I offended.
neil9999
08-28-2003, 05:28 AM
Thanks for all of your help, I'm just doing a little maths game so if(document.getElementById('next').value=="Next"){ document.getElementById('next').value='Enter'; will do just fine thanks.
Neil