By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,390 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,390 IT Pros & Developers. It's quick & easy.

Questions about Dynamicurl

P: 2
Hello. I admit that I don't know much about javascript. I'm pretty much relegated to only using html in webdesign. But I'm trying to do something and I think I may be close with dynamicurl in JS.

I found the following online tonight.

---------------
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. function dynamicurl()
  5. {
  6.     location.href = document.form1.test.value;
  7. }
  8. </script> 
  9. </head>
  10. <body>
  11. <form name="form1">
  12. <input type="text" name="test">
  13. <a href="#" onClick="dynamicurl();">Click Here</a>
  14. </form>
  15. </body>
  16. </html>
-------------------------------

When I put this into an html page, it pops up a small text box where the user can type in anything they want and click the "click here" button. When they do, they are linked from their current location to a folder named just what they typed.

For instance, if they type the word "javascript" into the text box and click the button, they are taken to

http://www.domain.com/javascript

Man, this is sooo close to what I need. I need something that does the same thing, but I'm wondering if there's any way to append something to the beginning and end of the text that was typed in. I want to take them to a particular picture instead of a folder. Using the text "javascript" as an example, I would want the dynamically generated url to be:

http://www.domain.com/bottom-javascript.jpg

So I'm basically adding "bottom-" (with the hyphen) BEFORE the text that was typed in, and then adding the ".jpg" at the end.

Is this something that could be done?

I'm guessing that this line:
location.href = document.form1.test.value;

Is the line that builds the link, but I'm afraid my knowledge of js is, well, I don't have any really......

If anyone in here knows the answer though, I'd be eternally grateful if you could shed some light.

Thanks
Beau
Feb 9 '07 #1
Share this Question
Share on Google+
2 Replies

P: 2
I figured it out. Wasn't used to having to use + signs between things that I wanted to show up. This works like a charm! Out of curiosity, would a script like the one below pull lots of system resources?



Hello. I admit that I don't know much about javascript. I'm pretty much relegated to only using html in webdesign. But I'm trying to do something and I think I may be close with dynamicurl in JS.

I found the following online tonight.

---------------
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. function dynamicurl()
  5. {
  6.     location.href = document.form1.test.value;
  7. }
  8. </script> 
  9. </head>
  10. <body>
  11. <form name="form1">
  12. <input type="text" name="test">
  13. <a href="#" onClick="dynamicurl();">Click Here</a>
  14. </form>
  15. </body>
  16. </html>
-------------------------------

When I put this into an html page, it pops up a small text box where the user can type in anything they want and click the "click here" button. When they do, they are linked from their current location to a folder named just what they typed.

For instance, if they type the word "javascript" into the text box and click the button, they are taken to

http://www.domain.com/javascript

Man, this is sooo close to what I need. I need something that does the same thing, but I'm wondering if there's any way to append something to the beginning and end of the text that was typed in. I want to take them to a particular picture instead of a folder. Using the text "javascript" as an example, I would want the dynamically generated url to be:

http://www.domain.com/bottom-javascript.jpg

So I'm basically adding "bottom-" (with the hyphen) BEFORE the text that was typed in, and then adding the ".jpg" at the end.

Is this something that could be done?

I'm guessing that this line:
location.href = document.form1.test.value;

Is the line that builds the link, but I'm afraid my knowledge of js is, well, I don't have any really......

If anyone in here knows the answer though, I'd be eternally grateful if you could shed some light.

Thanks
Beau
Feb 9 '07 #2

acoder
Expert Mod 15k+
P: 16,027
I figured it out. Wasn't used to having to use + signs between things that I wanted to show up. This works like a charm! Out of curiosity, would a script like the one below pull lots of system resources?
Glad you got it working by yourself! Another way to access objects is to use the id:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("test").value
This is the some as
Expand|Select|Wrap|Line Numbers
  1. document.form1.test.value
as long as you set the id for the test input box to "test".

What do you mean by pulling lots of system resources? Do you mean accessing files?
Feb 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.