40 users online (1 members and 39 guests)  


Page 1 of 5 1 2 3 4 5 Last
  Results 1 to 15 of 70

Related

  1. Replies: 0
  2. open url from text box    Forum: Javascript Forum
    Replies: 1
  3. how to open save/open dialog using HTML    Forum: HTML Forum
    Replies: 1
  4. open url from text box    Forum: Javascript Forum
    Replies: 5
  1. #1
    jeronimo's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2006
    Posts
    3

    open url from text box? pls help

    Hi, I am new here and I was wondering if someone could help me out doing this:

    I want a textbox on a school webpage, a student types in his-her studentnumber, like ´7928´, then presses ´ok´ en the page 7928.htm will load.
    Is there a simple way to do this?

  2. #2
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help


    Hi there jeronimo,

    and a warm welcome to these forums.

    Try this example, it may suit your requirements...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    <!--
    
    #container {
        width:195px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:auto;
     }
    #container h1 {
        font-size:1em;
        margin:0 0 10px 0;
     }
    
    -->
    </style>
    
    <script type="text/javascript">
    <!--
    
    window.onload=function() {
       df=document.forms[0];
       df[0].focus();
       df[1].onclick=function() {
    if((isNaN(df[0].value))||(df[0].value=='')) {
       alert('please insert your student number');
       df.reset();
       df[0].focus();
       return;
     }
    location.href=df[0].value+'.htm';
      }
     }
    
    //-->
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div id="container">
    <h1>enter student number</h1>
    <input type="text"/>
    <input type="button" value="OK"/>
    </div>
    </form>
    
    </body>
    </html>

  3. #3
    jeronimo's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2006
    Posts
    3

    Re: open url from text box? pls help

    Yes!
    Thanks! That works!
    Only I have 2 more questions:
    1. user has to click 'ok', the 'enter' button doesn't do anything
    2. if a student types a wrong number, is it possible to reload the page? I do have a list of alle numbers which are used

  4. #4
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help


    Hi there jeronimo,

    here is the amended code, it should suit your requirements...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    <!--
    
    #container {
        width:195px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:auto;
     }
    #container h1 {
        font-size:1em;
        margin:0 0 10px 0;
     }
    
    -->
    </style>
    
    <script type="text/javascript">
    <!--
    
    window.onload=function() {
    
       numbers=new Array(123,456,789,246,842,666,314); //replace these numbers with the student numbers
       df=document.forms[0];
       df[0].focus(); 
    
       df[1].onclick=function() {
    if((isNaN(df[0].value))||(df[0].value=='')) {
       alert('please insert your student number');
       df.reset();
       df[0].focus();
       return;
     }
    
    for(c=0;c<numbers.length;c++) {
    if(numbers[c]==df[0].value) {   
       location.href=df[0].value+'.htm';
       return;
      }
     }
    
    if(numbers[c]!=df[0].value) {
    alert('this number is invalid\n\nplease insert your student number');
       df.reset();
       df[0].focus();
       return;
       }
      }
     }
    
    //-->
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div id="container">
    <h1>enter student number</h1>
    <input type="text"/>
    <input type="button" value="OK"/>
    </div>
    </form>
    
    </body>
    </html>

  5. #5
    jeronimo's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2006
    Posts
    3

    Re: open url from text box? pls help

    and thank you again!!
    when the holidays are over I will use your code and upload it to our side!

  6. #6
    Balloony2's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2010
    Posts
    2

    Re: open url from text box? pls help

    Quote Originally Posted by coothead View Post

    Hi there jeronimo,

    and a warm welcome to these forums.

    Try this example, it may suit your requirements...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    <!--
    
    #container {
        width:195px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:auto;
     }
    #container h1 {
        font-size:1em;
        margin:0 0 10px 0;
     }
    
    -->
    </style>
    
    <script type="text/javascript">
    <!--
    
    window.onload=function() {
       df=document.forms[0];
       df[0].focus();
       df[1].onclick=function() {
    if((isNaN(df[0].value))||(df[0].value=='')) {
       alert('please insert your student number');
       df.reset();
       df[0].focus();
       return;
     }
    location.href=df[0].value+'.htm';
      }
     }
    
    //-->
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div id="container">
    <h1>enter student number</h1>
    <input type="text"/>
    <input type="button" value="OK"/>
    </div>
    </form>
    
    </body>
    </html>

    Hi, yet another newbie here...


    How can I adapt the above code to allow letters/words/numbers? Eg, if the user enters ABC123 i want to load a webpage called ABC123.hml the above example only allows numbers.Also I need it to default to lowercase.

    Thanks in advance.

  7. #7
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help

    Hi there Balloony2,

    and a warm welcome to these forums.

    does this help...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <style type="text/css">
    
    #container {
        width:195px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:auto;
     }
    #container h1 {
        font-size:1em;
        margin:0 0 10px 0;
     }
    
    </style>
    
    <script type="text/javascript">
    
    function init() {
    
    /******* replace these numbers with the student numbers ******/
    
       numbers=[          
                'abc123','zxy456','mnbc789',
                'balloony2','jdre842','ttty666',
                'mno314','rat404','long999'
               ]; 
    
    /*************************************************************/
    
       df=document.forms[0];
       df[0].focus(); 
    
    df[0].onkeyup=function(){
       this.value=this.value.toLowerCase();
     }
    
       df[1].onclick=function() {
    
    
    for(c=0;c<numbers.length;c++) {
    if(numbers[c]==df[0].value) {   
       location.href=df[0].value+'.html';
       return;
      }
     }
    
    if(numbers[c]!=df[0].value) {
    alert('this number is invalid\n\nplease insert your student number');
       df.reset();
       df[0].focus();
       return;
       }
      }
     }
    
    if(window.addEventListener){
       window.addEventListener('load',init,false);
     }
    else { 
    if(window.attachEvent){
       window.attachEvent('onload',init);
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div id="container">
    <h1>enter student number</h1>
    <input type="text">
    <input type="button" value="OK">
    </div>
    </form>
    
    </body>
    </html>
    
    Note:-

    The input value is changed to lowercase on key up.

  8. #8
    Balloony2's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2010
    Posts
    2

    Re: open url from text box? pls help

    Thanks very much for that, 100%.

  9. #9
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help

    No problem, you're very welcome.

  10. #10
    CK Productions's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2010
    Posts
    1

    Question Open URL from text field

    Hi, I'm also trying to open an url from a text box, only in a different way:

    Just like the student number; people need to fill in a number in the text field that is give to them for example: CKP001

    I want the script to put this input at the end of an address (https://secure.domain.com/)

    The problem why I can't use the script above is because it doesn't go outside it's directory.
    If the input is correct it should then go to a secure directory (https://secure.domain.com/CKP001).

    In other words: I need a javascipt to paste the text input behind a (non-variable) address. (people should insert it on their own,
    so it shouldn't be readable in the script itself, and doesn't need a "input was incorrect" text)

    I've been trying to change the script above but without succes =P.

    Hope you can help me!
    Last edited by HTML; 03-24-2010 at 07:05 AM.

  11. #11
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help

    Hi there CK Productions,

    and a warm welcome to these forums.

    Do you want something like this...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <style type="text/css">
    
    #container {
        width:195px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:auto;
     }
    #container h1 {
        margin:0 0 10px 0;
        font-size:1em;
        text-align:center
     }
    
    </style>
    
    <script type="text/javascript">
    
    function init() {
    
       df=document.forms[0];
       df[0].focus(); 
    
       df[1].onclick=function() {  
       location.href='https://secure.domain.com/'+df[0].value;
       return;
      }
     }
    
    if(window.addEventListener){
       window.addEventListener('load',init,false);
     }
    else { 
    if(window.attachEvent){
       window.attachEvent('onload',init);
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div id="container">
    <h1>enter your code</h1>
    <input type="text">
    <input type="button" value="OK">
    </div>
    </form>
    
    </body>
    </html>
    
    ...or have I misunderstood your requirements.

  12. #12
    ralphreyes's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2010
    Posts
    5

    Smile Re: open url from text box? pls help

    Hi there, another newbie here, hate to add to this thread, but I also have a similar request.

    I would like to take coothead's example, but when you hit the OK button, it will create two different links with the text in the textbox, then open each of those links in their own iframe, all in the same main page, so that instead of leaving the page, I can change my text quickly and hit OK, without having to hit the back button in my browser.

    An example would be one iframe will open up a search in Google with the text from the textbox, and the other iframe will open up a search in yahoo with the same text from the textbox.

    I hope this makes sense

  13. #13
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help

    Hi there ralphreyes,

    and a warm welcome to these forums.

    Have a look at this example it may suit your requirements...
    Code:
    
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <style type="text/css">
    #body {
        margin:10px 0;
     }
    #container {
        width:205px;
        border:3px double #000;
        padding:10px;
        font-family:sans-serif;
        color:#000;
        background-color:#ccc;
        margin:0 auto 10px;
     }
    #container h1 {
        margin:0 0 10px 0;
        font-size:1em;
        text-align:center
     }
    #frames-holder {
        text-align:center;
     }
    #frames-holder iframe {
        width:48%;
        height:400px;
        margin:0 0.25%;
     }
    .none {
        display:none;
     }
    </style>
    
    <script type="text/javascript">
    
    function init() {
    
       df=document.forms[0];
       df.className='';
       df.reset();
       df[0].focus();
    
       obj1=document.getElementById('frames-holder');
       obj2=document.getElementById('fr1');
       obj3=document.getElementById('fr2');
    
       obj2.src=obj3.src='';
    
       df[1].onclick=function() { 
    
       obj1.className=''; 
       obj2.src='http://www.google.com/search?q='+df[0].value;
       obj3.src='http://search.yahoo.com/search?p='+df[0].value;
    
       return;
      }
     }
    
    if(window.addEventListener){
       window.addEventListener('load',init,false);
     }
    else { 
    if(window.attachEvent){
       window.attachEvent('onload',init);
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <form action="#" class="none">
    <div id="container">
     <h1>enter your search item</h1>
     <input type="text">
     <input type="button" value="OK">
    </div>
    </form>
    
    <div id="frames-holder" class="none">
     <iframe id="fr1"></iframe>
     <iframe id="fr2"></iframe>
    </div>
    
    </body>
    </html>
    

  14. #14
    ralphreyes's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2010
    Posts
    5

    Re: open url from text box? pls help

    That worked perfectly thank you coothead!

  15. #15
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: open url from text box? pls help

    No problem, you're very welcome.



Page 1 of 5 1 2 3 4 5 Last

Tags for this Thread