Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Javascript Help


ghost's Avatar
0 0

<form name="form1"> <select name="S1" size="4" onchange="document.form1.T1.value ='Cost:' + this.value"> <option value="0.99">Pencil</option> <option value="3.99">Paper</option> <option value="4.99">Pens</option> <option value="1.99">Ruler</option> <select><BR> <input type="text" name="T1" value="Pick an item above"> </form>

OK, with that coding, it works fine and everything, but I am trying to change the width/height of the input type value. I can't figure out how to do it. Well, I am like also trying to make it change size depending on the text, and can't manage to figure it out. Google hasn't been help either.


ghost's Avatar
0 0

Just set the CSS "width" property to whatever you want… For example:

var blah = document.getElementById(&quot;id&quot;);
blah.style.width = (10 * yourSelect.value.length) + &quot;px&quot;;

Which would make the box big enough for however many characters there are, assuming their all 10 pixels wide.