Jump to content

Function Doesn't Work


gloeg
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...