Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function with two arguments??? 1

Status
Not open for further replies.

The

Programmer
Jul 30, 2001
92
CA
I've looked it up on the internet, but all it tells me is how to make a function that will add two numbers when you click a link. Here's the code I have so far:

<script language=&quot;javascript&quot;>

function Start(x,y) {
var x=''
var y=''
var path='parent.main.document.location=(path)
}
</script>


and in the body;

<a href=&quot;javascript:Start('google.ca','something.html')&quot;>Something</a>


The google.ca and something.html are just examples for what I would put in. I don't know why this won't work. It worked perfectly when I tried it with only one argument. Can anyone help?
 
So, you want to take two strings in, append them with some sort of separator, then pop them back out?

Or are you more interested in building the whole link thing?

Curious,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
When you have (x,y) as parameters, don't redefine them
var x = ''; this is resetting it to blank.

HTH, Jessica [ponytails2]
 
Yeah, those are gonna pooch you fer sure. Heck, when I saw 'em, I thought they were single occurences of a double-quote and that that was some sort of assert-to-string thing. Glad you spotted that, Jessica!

Take 'em out:

Code:
<script language=&quot;javascript&quot;>

function Start(x,y) {
var path='[URL unfurl="true"]http://www.'+x+'/'+y;[/URL]
parent.main.document.location=(path);
}
</script>

I also added a couple of semicolons that might be unnecessary, but I'm a bit of a stickler on closure. [smile]

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Thanks, but I already tried it without declaring x and y. Also, it worked fine without semicolons before I added the y. In response to the first post, I don't exactly know what you mean about &quot;building the whole link thing&quot;, but basically the firs thing you said is what I want to do. I don't want to print the address, though, just make it so the link to it works.
 
Yeah, build the whole link. That's what I meant.

Smell this:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <script language=&quot;javascript&quot;>
      function Start(x,y)
        {
          var path='[URL unfurl="true"]http://www.'+x+'/'+y;[/URL]
          document.location=(path);
        }
    </script>

    <title>JavaScript Sample</title>
  </head>
  <body>
    <p><a href=&quot;javascript:Start('google.ca','something.html');&quot;>Link of Doom</a></p>
  </body>
</html>

Hope that helps!

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
well, thanks, but uh...how is that any different from what I had, except the semicolons?
 
>> well, thanks, but uh...how is that any different from
>> what I had, except the semicolons?

What kind of a post is that? Did you try it? It works. If yours does not, then.... that is how it is different at the very least.

It took me longer to write this post than it did to copy that solution into a file and execute it in a browser to see that IT WORKS!

LOL
-pete
 
Oh... and i am giving Edward a star just because i feel somewhat tweeked by the whole affair!

-pete
 
Hmm....well, that's exactly what I have, and it doesn't work for me......maybe I forgot to close a tag somewhere or something. Thanks, sorry if my post sounded a bit rude; I didn't mean it to be.
 
I see what I did. It was a very stupid, annoying, typo. Thanks everyone!
 
I have yet to see a brilliant typo. [smile] For the record, I try not to post code unless I've built it and verified that it works.[lol]

Glad it's working for ya'.

Thanks, Pete.

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top