NickBomb Posted June 14, 2007 Share Posted June 14, 2007 My script does'nt work as I want to...This is my java script: var name = ""; function alertname() { name = document.getElementById('textname'); alert('welcome, '+ namn +'!'); } This is the HTML: <input type="text" value="" size="20" name="textname" id="textname" maxlength="20"><br><br><input type="button" id="buttonbörjaspela" value="Go!" onClick="alertname()"> The alert says:Welcome, [object HTMLInputElement]!I have no idea what's wrong...Please help... Link to comment Share on other sites More sharing options...
Lulzim Posted June 14, 2007 Share Posted June 14, 2007 the problem was at the part in red color.To retrieve the text from the field you should use .value function alertname() { var name = document.getElementById('textname'); alert('welcome, '+ name.value +'!'); } Link to comment Share on other sites More sharing options...
NickBomb Posted June 14, 2007 Author Share Posted June 14, 2007 Thanks, I forgot that >.< Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.