Welcome to WebmasterWorld Guest from 3.228.24.192

Forum Moderators: open

Message Too Old, No Replies

Javascript just not running and acting like regular text

Not much more can be said....

     
2:29 am on Jun 26, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


I have a javascript code I just got ahold of and fixed up. What it is supposed to do is add a new input bar everytime you click the button. I think the script itself works but for some reason when you view it in a website it reads:
function¬ addtrack(){ ¬ ¬ ¬ var¬ addTrack¬ =¬ document.createElement("track"); input.type="text"; input.name="track"; input.size="20"; input.maxlength="50"; }

Here is basically what the page is:
<html>
<script†language="javascript">
function†addtrack(){
†††var†addTrack†=†document.createElement("track");
input.type="text";
input.name="track";
input.size="20";
input.maxlength="50";
}
</script>
<body>
Track:
<input name="track" type="text" size="20" maxlength="50">
<button onclick="track();">MORE TRACKZ!</button>
</body>
</html>

Thanks in advance!

4:58 am on June 26, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


TRY

<html>
<head>
<script language="javascript">
function addtrack(){
var addTrack = document.createElement("track");
addTrack.type="text";
addTrack.name="track";
addTrack.size="20";
addTrack.maxlength="50";
.. more code here to add addTrack to page ..
}
</script>
</head>
<body>
Track:
<input name="track" type="text" size="20" maxlength="50">
<button onclick="addtrack();">MORE TRACKZ!</button>
</body>
</html>

5:06 am on June 26, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


Still not working. I did exactly what you said and I'm still getting the same thing (I don't want to exactly call it an error....):
function¬ addtrack(){ ¬ ¬ ¬ var¬ addTrack¬ =¬ document.createElement("track"); addTrack.type="text"; addTrack.name="track"; addTrack.size="20"; addTrack.maxlength="50"; }

I get that at the top of the page.

5:06 am on June 26, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Sept 5, 2007
posts:264
votes: 0


The script itself ain't working - something happens onclick, yes, but not what you want. So working, no.

Try this and see how it works for you. It will probably still need work in placing the input where you want it to go but it at least should add a text input to the page putting you halfway there.

Here is basically what the page is:
<html>
<script language="javascript">
function makeaddtrack(){
var addTrack = document.createElement("input");
addTrack.type="text";
addTrack.name="track";
addTrack.size="20";
addTrack.maxlength="50";
document.body.appendChild(addTrack);
}
</script>
<body>
Track:
<input name="track" type="text" size="20" maxlength="50">
<button onclick="makeaddtrack();">MORE TRACKZ!</button>
</body>
</html>

5:17 am on June 26, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


Well I got my first problem working but now the button isn't doing what it is supposed to do. It just doesn't create an input bar when clicked. I did what you said Poppy but it still doesn't work.

[edited by: Spiceydog at 5:23 am (utc) on June 26, 2008]

7:28 am on June 26, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


Try adding the head tags, may not be issue but won't harm.
7:34 am on June 26, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


Unfortunately I already tried that and it didn't work. Lucky for me I finally googled the right combination of words <snip>
works perfectly! wooooo

[edited by: engine at 9:57 am (utc) on June 27, 2008]
[edit reason] No urls, thanks [/edit]