anthonyv Posted May 17, 2007 Share Posted May 17, 2007 Hi all, wondering if you could assist me with something i know is quite simple, though i don't know the correct syntax to code it myself... I have a simple html page with a single textbox. I require that a user enters a value into the textbox (their User ID) and this will be used to create a hyperlink. So, if the user entered “anthony” into the textbox, the “go” (submit) button beside it would open the page: http://www.anthony.mydomain.com in a new browser window. If they entered “Jimmy” into the textbox, the “go” button b would open the page http://www.harry.mydomain.com in a new browser window. I kno this is real simple, but as i mentioned, I just don’t know the correct javascript syntax to read and parse the textbox values. This is a non-working example of what i think it will look like... i'd be grateful if someone could correct me (this is how i learn). <html> <head> <title>New Page 1</title> </head> <body> <script language=javascript> function getlink (form) { var thelink = form.userid.value; } </script> <form name="form" method="POST" action="javascript:getlink()"> <p align="center">Please enter your User ID to view<br> your personalised preview:<br> <input type="text" name="userid" size="20"><br> <input type="submit" value="Submit" name="getlink" onclick="<a href="http://www.$thelink.mydomain.com"></p> </form> </body> </html> Any assistance would be much appreciated. Thanks in advance, Anthony. Quote Link to comment Share on other sites More sharing options...
anthonyv Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, searching google i got this far, but something wrong in creating the correct hyperlink: <html> <head> <title>New Page 1</title> </head> <body> <script language="Javascript"> function goURL() string UserID; UserID = userid.textbox.value; location.href="http://www.?id=" + txtTemp;.google.com; </script> <form name="form" method="POST" action="goURL()"> <p align="center">Please enter your User ID to view<br> your personalised preview:<br> <input type="text" name="userid" size="20"><br> <input type="submit" value="Submit"></p> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
xenophobia Posted May 17, 2007 Share Posted May 17, 2007 <html> <head> <title>New Page 1</title> </head> <body> <script language=javascript> function getlink (f) { var url = f.userid.value; url = "http://www." + url + ".mydomain.com"; window.open(url, 500, 500); //go google search for more of this function's properties. } </script> <form name="form" method="POST" action="javascript:getlink(document.form)"> <p align="center">Please enter your User ID to view<br> your personalised preview:<br> <input type="text" name="userid" size="20"><br> <input type="submit" value="Submit" name="getlink" onclick="<a href="http://www.$thelink.mydomain.com"></p> </form> </body> </html> Buddy... hope this help you. Quote Link to comment Share on other sites More sharing options...
anthonyv Posted May 17, 2007 Author Share Posted May 17, 2007 Thank you so much. Appreciate your quick response and your support. Works perfectly! Cheers, Anthony. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.