Displaying the value in combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepthisoft
    New Member
    • Jul 2007
    • 27

    #1

    Displaying the value in combobox

    hi,

    I want to change the combobox displaying value depending up on the action value. This is the example code,
    [code=html]
    <html>
    <head>
    </head>
    <script Language="JavaS cript">
    function check(action)
    {
    if(action=="hou rly")
    {
    //code insert here
    //this action equals hourly i have to display the Hourly in the combobox.
    }
    }
    </script>
    <body onLoad="check(' hourly')">
    <SELECT name=NavBox id="NavCo">
    <OPTION>Defau lt
    <OPTION>Hourl y
    <OPTION>Daily
    <OPTION>Monthly </OPTION>
    </SELECT>
    </body>
    </html>
    [/code]


    How can i do this.

    Thanks in advance.
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    Code:
    <html>
    <head>
    </head>
    <script Language="JavaScript">
    function check(action)
    {
      document.getElementById('NavCo').value = action;
    }
    </script>
    <body onLoad="check('hourly')">
      <SELECT name=NavBox id="NavCo">
        <OPTION value="default">Default</OPTION>
        <OPTION value="hourly">Hourly</OPTION>
        <OPTION value="daily">Daily</OPTION>
        <OPTION value="monthly">Monthly</OPTION>
      </SELECT>
    </body>
    </html>
    Maybe setting value for each option is not looking good, but it works in all browsers. :)

    Comment

    Working...