inserting a variable into a MM_goToURL link

Discussion in 'HTML and CSS' started by s3s3, Feb 29, 2012.

  1. s3s3

    s3s3

    Joined:
    Feb 29, 2012
    Messages:
    2
    I am new to this, and after I've searched a bunch of forums and tried it on my own I didn't succed in accomplishing what I wanted, i.e. :

    I want to have a text field, in which I will write a number. Then i want a Button to have a MM_goToURL on click action to a Link which has a variable in it with the value from the input text field.

    To be more precise here is a part of the code:

    the MM_goToURL function:

    <script type="text/javascript">
    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
    }
    </script>

    My text field:

    <input name="12" type="text" id="ip" value="1" />

    My Button:

    <input name="3" type="submit" id="GO" onclick="MM_goToURL('parent','1.1.1.my_var');return document.MM_returnValue" value="Submit" />
    <label for="1"></label>

    So how can I declare my_var so it will always take the value inside the Input text field, and how do I include that variable inside the link, because just plain writing the name of the variable in there like :MM_goToURL('parent','1.1.1.my_var') won't work.

    Thank you.
     
    s3s3, Feb 29, 2012
    #1
    1. Advertising

  2. s3s3

    s3s3

    Joined:
    Feb 29, 2012
    Messages:
    2
    I got it working but with another function not MM_gotoURL

    <script type="text/javascript">
    function doit1() {
    var x = document.getElementById('ip1').value
    window.open('http://1.1.1.'+x)
    }
    </script>

    <input type="submit" name="first" id="first" onclick='doit1()' value="Go to Board" />
    <input name="ip" type="text" id="ip1" value="" size="10"/>
     
    s3s3, Mar 1, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    862
    Kevin Spencer
    May 17, 2005
  2. evandela@bigpond.net.au
    Replies:
    2
    Views:
    2,690
    gella
    Mar 29, 2006
  3. Sura
    Replies:
    4
    Views:
    2,343
    Jan C. Faerber
    Oct 28, 2009
  4. Navillus

    Inserting variable into hidden input

    Navillus, Mar 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    203
    Jonas Raoni
    Mar 7, 2006
  5. hgraham@bcbsal.org
    Replies:
    14
    Views:
    173
Loading...

Share This Page