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.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help for fixing a code

    Hi,

    I don´t know as fix the variable "i". Any help would be appreciated.

    <form method="get" name="form1">
    <select name="teams">
    <OPTION VALUE="http://www.cdc.gov/obesity/causes/economics.html">Obesity
    <OPTION VALUE="http://www.despair.com/economics.html">Economics
    <OPTION VALUE="http://nobelprizes.com/nobel/economics/">Nobel
    <OPTION VALUE="http://ideas.repec.org/s/rio/texdis.html">Economia
    <OPTION VALUE="http://www.cervantesvirtual.com">Cervantes Virtual
    </select>
    </form>
    <br>

    <script type="text/javascript" language="javascript">
    if (i=<document.form1.teams.options.length{
    document.write('<input type=text + value="' + document.form1.teams.options[i].value +'">');
    }
    </script>
    Letchev

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,145
    Thanks
    38
    Thanked 505 Times in 499 Posts
    What is it that you are trying to do?
    This is just a guess!

    Code:
    <form method="get" name="form1">
    <select name="teams">
    <OPTION VALUE="http://www.cdc.gov/obesity/causes/economics.html">Obesity
    <OPTION VALUE="http://www.despair.com/economics.html">Economics
    <OPTION VALUE="http://nobelprizes.com/nobel/economics/">Nobel
    <OPTION VALUE="http://ideas.repec.org/s/rio/texdis.html">Economia
    <OPTION VALUE="http://www.cervantesvirtual.com">Cervantes Virtual
    </select>
    </form>
    <br>
    
    <script type="text/javascript" language="javascript">
    var i=0;
    do {
      document.write('<input type=text + value="' + document.form1.teams.options[i].value +'">');
      i++;
    } while (i<document.form1.teams.options.length);
    </script>

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    heres my guess ...

    Code:
    <script type="text/javascript"> 
    var teamSelected = function(){
    	document.getElementById("displayTeam").innerHTML=
    		" selected item number = " + 
    			document.forms["form1"].elements["teams"].selectedIndex +
    		"<br> selected option = " +
    			document.forms["form1"].elements["teams"].options[document.forms["form1"].elements["teams"].selectedIndex].text +	
    		"<br> selected value = " +
    			document.forms["form1"].elements["teams"].options[document.forms["form1"].elements["teams"].selectedIndex].value;	
    }
    </script> 
    
    
    
    
    <form method="get" name="form1">
    <select name="teams" onchange="teamSelected()"> 
    <OPTION VALUE="http://www.cdc.gov/obesity/causes/economics.html">Obesity 
    <OPTION VALUE="http://www.despair.com/economics.html">Economics
    <OPTION VALUE="http://nobelprizes.com/nobel/economics/">Nobel 
    <OPTION VALUE="http://ideas.repec.org/s/rio/texdis.html">Economia 
    <OPTION VALUE="http://www.cervantesvirtual.com">Cervantes Virtual 
    </select> 
    </form> 
    <br> 
    <div id="displayTeam"></div>

  • #4
    New Coder
    Join Date
    May 2005
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for jmrker and DaveyErwin,

    Regarding the question of jmrker, behind the scene there is other code...

    I would need help to fix just the different links in one input only. At the present time except by the code of DaveyErwin (but it not works fine with the rest of the code. Alone yes) , the links are shown in inputs as much as links and I need in other way: several links in one input.

    Obs: The options menu is changed automatically by settimeout. Each 10 seconds is shown 1 link in the INPUT... but this is subject for other thread!


    Letchev
    Last edited by letchev; 08-29-2010 at 08:55 PM.


  •  

    Posting Permissions

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