View Full Version : change type from hidden to text

05-05-2004, 03:07 PM
Hi there,

got a function that's supposed to change the class and type of a element from hidden to text depending on user input.

the initial element is hidden:
<input name="newUcompanyVatNum" type="hidden" class="" id="newUcompanyVatNum" value="" size="40" maxlength="60">

and I've got a function which to change the class, type:

document.getElementById('newUcompanyVatNum').className = "RequiredTextBox";
document.getElementById('newUcompanyVatNum').type = "text";

it's changing the class, but not the type? ie is saying that
Could not get the type property. this command is not supported

Have I just got the syntax wrong? how do I change the type to text?

Thanks in advance

Roy Sinclair
05-05-2004, 04:33 PM
You can't change the "type". If you want to display or hide a text element then make it a text element and change it's CSS DISPLAY property to hide or display it.

05-05-2004, 05:41 PM
thanks for that,

just took a break from the 'tom hooter' and realised that I could do it another way, so now I'm not trying to change the type, but using

<span id="vatBox">&nbsp;</span>

and the following javascript to change it into a text box

document.getElementById('vatBox').innerHTML ="<input name=\"newUcompanyVatNum\" type=\"text\" class=\"\" id=\"newUcompanyVatNum\" value=\"\" size=\"40\" maxlength=\"60\">";