Questions about Dynamicurl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beauzeau
    New Member
    • Feb 2007
    • 2

    Questions about Dynamicurl

    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.

    ---------------
    Code:
    <html>
    <head>
    <script>
    function dynamicurl()
    {
        location.href = document.form1.test.value;
    }
    </script> 
    </head>
    <body>
    <form name="form1">
    <input type="text" name="test">
    <a href="#" onClick="dynamicurl();">Click Here</a>
    </form>
    </body>
    </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
  • beauzeau
    New Member
    • Feb 2007
    • 2

    #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?



    Originally posted by beauzeau
    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.

    ---------------
    Code:
    <html>
    <head>
    <script>
    function dynamicurl()
    {
        location.href = document.form1.test.value;
    }
    </script> 
    </head>
    <body>
    <form name="form1">
    <input type="text" name="test">
    <a href="#" onClick="dynamicurl();">Click Here</a>
    </form>
    </body>
    </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

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by beauzeau
      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:
      Code:
      document.getElementById("test").value
      This is the some as
      Code:
      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?

      Comment

      Working...