Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Very Basic Question, using user entry, please help?

    I need to get an entry from the user and then add it to a url in a link <a href>
    How can that be done?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Could be something like this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    var defaultHref;
    function changeLink(v){
    document.getElementById('mylink').href=defaultHref+v;
    }
    onload=function(){
    defaultHref=document.getElementById('mylink').href;
    }
    </script>
    </head>
    <body>
    <form>
    <input type="text" onkeyup="changeLink(this.value)" onblur="changeLink(this.value)">
    </form>
    <a href="http://google.com" id="mylink">mylink</a>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    bojomojo (04-24-2008)

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it is working, thank you for your great help

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i have 2 more questions:

    1. I need to add something to the link after the user entry

    2. I want to hide that code so that noone can see it when they read the source

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    2. I want to hide that code so that noone can see it when they read the source
    http://www.codingforums.com/showthre...173#post182173
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    okay, but cant i use it in php so that its not viewd

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by bojomojo View Post
    I want to hide that code so that noone can see it when they read the source
    Sure, why not? As easy as a perpetuum mobile

    No way, pard, you can not hide (at least not for a medium skilled programmer) client-side codes (HTML, CSS, Javascrip)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by bojomojo View Post
    okay, but cant i use it in php so that its not viewd
    In this case you must submit the value to a php application which will add the value to a link written in that php application and will open the new page.

    But, as long as the user will go anyway on that page, why to hide it's link? On the other hand, as a user, if you invite me to open a link but I don't see the url in my status bar, I refuse to click, as I suspect that you try to cheat me or drive me where I don't like (phishing sites, poisoned sites... and so on)
    Last edited by Kor; 04-24-2008 at 04:16 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #9
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    no, i dont want to hide the link, i want to hide the process itself, can you tell me how to do that php thing

  • #10
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by bojomojo View Post
    no, i dont want to hide the link, i want to hide the process itself, can you tell me how to do that php thing
    What process? You add a value (which is known, as the user input it) to a url (which is known, as you can see it when you roll over the link). What's so special in it to hide it? A php solution makes no difference: the same known value added to the same known url. Nothing to be hide, nothing can be hide... I don't get it. What is your final aim, after all?
    Last edited by Kor; 04-24-2008 at 04:30 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #11
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes that it true i found the technique so simply but it took some time, so i dont want other people to just copy the technique

  • #12
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    how can i add a value after the part that the user input
    for exacmple the user puts google
    and i want it to be google.com

  • #13
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    Code:
     
    <script type = "text/javascript">
    var mystery_element = "<?= your_php_var ?>";
    </script>
    ...
    kor's technique here excepting add mystery_element to the value
    you're assigning to the href of your link
    ...
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #14
    New Coder
    Join Date
    Apr 2008
    Posts
    22
    Thanks
    1
    Thanked 0 Times in 0 Posts
    sorry i dont understand fully

  • #15
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    you said you wanted to use php, so that which creates the code for this page would be your php file. it's pretty simple

    Code:
     
    <?
    //Your secret ingredients here (so that noone knows what's in the special sauce)
    //ultimately resulting in the aptly named variable $the_special_sauce
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    var defaultHref;
    var mystery_element = "<?= $the_special_sauce ?>";
    function changeLink(v){
    document.getElementById('mylink').href=defaultHref+v+mystery_element;
    }
    onload=function(){
    defaultHref=document.getElementById('mylink').href;
    }
    </script>
    </head>
    <body>
    <form>
    <input type="text" onkeyup="changeLink(this.value)" onblur="changeLink(this.value)">
    </form>
    <a href="http://google.com" id="mylink">mylink</a>
    </body>
    </html>
    if you are, however, talking about posting data asynchronously to your php page to have some process executed on it so it can be returned to the calling function and appended to the link, methinks you should look into a little ajax
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •