CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2008
    Posts
    142

    [RESOLVED] How to open page when i click on Option values

    Hi,

    In my application i am using Dropdown option values. when i click on one of the option values it will open a page. I am using following code. It shows errors. Could you please help on this one ??

    Code:
    <select name=CATEGORY class=selInput>" );
          
          <option value=\"#\"> ---------------- </option>
          <option value="ozSetupOptValues.jsp?id=SLS_CUSTOMER_CATEGORY"> manage            accounts</option>  // in this line it gives problem  
          </select>
    thanks in advance....
    Last edited by PeejAvery; April 16th, 2009 at 08:31 PM. Reason: Fixed code tags.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: How to open page when i click on Option values

    This is a very simple task. Any Google search could have given you the answer. There's even one on this very page called "Forum Jump."

    Code:
    <select onchange="window.location=this.value">
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jun 2008
    Posts
    142

    Re: How to open page when i click on Option values

    In my dropdown i have 5-6 values. But i want to go that link(ozSetupOptValues.jsp?id=SLS_CUSTOMER_CATEGORY") when i choose that specific value , which i mentioned above (Manage Accounts).

    thanks

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: How to open page when i click on Option values

    Look back at my previous post. I already gave you the answer!
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jun 2008
    Posts
    142

    Re: How to open page when i click on Option values

    Thanks for reply. I have 5-6 fields in drop down. But when i click on "ManageAccount" option they only it should invoke. I tried in the following way.
    Code:
      <select name=CATEGORY class=selInput onchange="onChange=go();">
    <option value="sample1">sample1</option>
    <option value="sample2">sample2</option>
    <option value=\"#\"> ---------------- </option>
    <option value="manageaccount"> manage accounts</option>
    </select>
    
    <head>
    <script>
       function go() {
                  window.location = "ozSetupOptValues.jsp?id=SLS_CUSTOMER_CATEGORY";
           }
    </script>
    </head>
    It is calling the JS function when i choose every option. But i need to invoke the JSP when i choose "Manage Accounts" only. Can you an idea on this ??

    thanks ..

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: How to open page when i click on Option values

    So you need to pass this as a parameter of the go() function. From within the function, you can check the value of the selected item of the <select> tag but using the parameter.

    Code:
    <script type="text/javascript">
    function go(select) {
      if (select.value == 'manageaccount') {window.location = 'ozSetupOptValues.jsp?id=SLS_CUSTOMER_CATEGORY';}
    }
    </script>
    
    <select name="CATEGORY" class="selInput" onchange="go(this)">
      <option value="sample1">sample1</option>
      <option value="sample2">sample2</option>
      <option value=\"#\"> ---------------- </option>
      <option value="manageaccount"> manage accounts</option>
    </select>
    This really is very basic JavaScript. I highly suggest that you read up on some tutorials before proceeding and doing more scripting!
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Jun 2008
    Posts
    142

    Re: How to open page when i click on Option values

    It's not working. It is enter into the go() . but the JSP is not invoking at any time.
    Last edited by adusumalli; April 17th, 2009 at 04:55 PM.

  8. #8
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: How to open page when i click on Option values

    The code is correct, the problem must be with your JSP name or context.
    Change select var name to something else, this is a reserved word, some browsers may have trouble understanding it.
    Last edited by Xeel; April 17th, 2009 at 05:17 PM.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  9. #9
    Join Date
    Jun 2008
    Posts
    142

    Re: How to open page when i click on Option values

    Now it's getting. thanks.
    Last edited by adusumalli; April 17th, 2009 at 05:41 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
  •  





Click Here to Expand Forum to Full Width

Featured