Jump to content

Function Doesn't Work


gloeg

Recommended Posts

why isn't the funtion gitaar working??i don't get it :)

<html><head><script type="text/javascript">function gitaar (artist,song){websitebasis="http://www.ultimate.guitar.com/";letter=artist.charAt(0);website=websitebasis+letter+"/"+artist+"/"+song+".ptb";alert("gelukt");document.write('<a href="'+website+'">link</a>;}</script></head><body><h1>guitartab opzoeken</h1><form><input type="text" name="artist" value="artist"><input type="text" name="song" value="song"><input type="button" onclick="gitaar (artist.value,song.value)" value="download"></form></body></html>

Link to comment
Share on other sites

Because it is not receiving any data. Try this:<input type="button" onclick="gitaar (this.form.artist.value, this.form.song.value)" value="download">"this" refers to the button. "form" refers to the form that contains the button. The form has an element named "artist." Going up and down the tree like this is the only way you can get a reference to the element by using its name.Now, you realize that your document.write() statement is going to make your original page disappear, right? You might prefer something like this:window.location = website;

Link to comment
Share on other sites

thanx for the help but I'm sorry, :) it still doesn't work

<html><html><head><script type="text/javascript">function gitaar(artist,song){websitebasis="http://www.ultimate.guitar.com/";letter=artist.charAt(0);website=websitebasis+"/"+letter+"/"+artist+"/"+song+".ptb";windows.location=website</script></head><body><h1>guitartab opzoeken</h1><form><input type="text" name="artist" value="artist"><input type="text" name="song" value="song"><input type="button" onclick="gitaar(this.form.artist.value, this.form.song.value)" value="download"></form></body></html>

Link to comment
Share on other sites

1. You didn't copy this line correctly:window.location = website;You added an "s" to window.2. You deleted the closing } at the end of your gitaar function. We're all happy to help on this board, but please check the basics.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...