www.webdeveloper.com
Results 1 to 4 of 4

Thread: I want to execute other files

  1. #1
    Join Date
    Apr 2009
    Posts
    2

    I want to execute other files

    I have this code.
    when I choose CODE option, run option1.php, and
    when I choose NAME option, run option2.php.
    But I need to change option1.php to code.php and option2.php to name.php.

    Can you help me?


    <html>
    <head>
    <script language="javascript">
    var redireccionar = function(valor) {
    // get checked first...
    var selected, len = valor.length; //
    while(len--) {
    if (valor[len].checked)
    selected = valor[len].value;
    }

    document.getElementById("formulario").setAttribute("action", "./OPTION"+selected+".PHP");
    document.getElementById("formulario").submit();
    };

    window.onload = function() {
    document.getElementById("button").onclick = function() {
    redireccionar(document.formulario.opciones);
    };

    document.getElementById("texto").onmouseover = function() {
    this.focus();
    };
    };

    </script>
    </head>
    <body>
    <form name="formulario" id="formulario" method="post">
    <input type="radio" name="opciones" value="1" checked="checked">CODE:
    <input type="radio" name="opciones" value="2">NAME:
    <input type="text" name="Texto" id="texto">
    <input type="button" name="Boton" id="button" value="Search">
    </form>
    </body>
    </html>

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    try this change:
    Code:
    //javascrpt:
    document.getElementById("formulario").setAttribute("action", "./" + selected + ".php");
    
    //html:
    <input type="radio" name="opciones" value="code" checked="checked">CODE:
    <input type="radio" name="opciones" value="name">NAME:

  3. #3
    Join Date
    Apr 2009
    Posts
    2
    OPSS!!!!
    It was so easy !

    I want to erase the input text when I change the raddio button.
    How I do that ?

  4. #4
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    set the field with an empty string after setting the action attribute.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles