Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Script issue

Script issue

Scheduled Pinned Locked Moved ASP.NET
helpjavascripthtmlsysadmintools
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Priya S
    wrote on last edited by
    #1

    Html Side -------- asp:DropDownList ID="ddlSecurityQues" AutoPostBack="false" runat="server" Width="279px" OnSelectedIndexChanged="javascript:showownques();"> script ------ function showownques(value) { if(value==9) { txtOwnQues.Visible = true; SetFocus(txtOwnQues); } else { txtOwnQues.Visible = false; SetFocus(txtAnswer); } } } PROBLEM: not calling the function showonques(ddlSecurityQues.SelectedIndex)

    Thanks in advance, Priya.

    J B 2 Replies Last reply
    0
    • P Priya S

      Html Side -------- asp:DropDownList ID="ddlSecurityQues" AutoPostBack="false" runat="server" Width="279px" OnSelectedIndexChanged="javascript:showownques();"> script ------ function showownques(value) { if(value==9) { txtOwnQues.Visible = true; SetFocus(txtOwnQues); } else { txtOwnQues.Visible = false; SetFocus(txtAnswer); } } } PROBLEM: not calling the function showonques(ddlSecurityQues.SelectedIndex)

      Thanks in advance, Priya.

      J Offline
      J Offline
      John ph
      wrote on last edited by
      #2

      Priya Cool wrote:

      OnSelectedIndexChanged="javascript:showownques();">

      where is the parameter?

      Priya Cool wrote:

      PROBLEM: not calling the function showonques(ddlSecurityQues.SelectedIndex)

      pass the parameter on the function call...

      Regards
      J O H N :rose:
      "Even eagles need a push." David McNally


      P 1 Reply Last reply
      0
      • J John ph

        Priya Cool wrote:

        OnSelectedIndexChanged="javascript:showownques();">

        where is the parameter?

        Priya Cool wrote:

        PROBLEM: not calling the function showonques(ddlSecurityQues.SelectedIndex)

        pass the parameter on the function call...

        Regards
        J O H N :rose:
        "Even eagles need a push." David McNally


        P Offline
        P Offline
        Priya S
        wrote on last edited by
        #3

        i hv passed it. sorry fr not mentioning but still not working

        Thanks in advance, Priya.

        J 1 Reply Last reply
        0
        • P Priya S

          i hv passed it. sorry fr not mentioning but still not working

          Thanks in advance, Priya.

          J Offline
          J Offline
          John ph
          wrote on last edited by
          #4

          showonques(ddlSecurityQues.SelectedIndex)-- This is wrong. This (ddlSecurityQues.SelectedIndex) doesn't work on the client-side. try the below function without passing the parameter. It may work. function showownques() { var value = document.getElementById("ddlSecurityQues")[document.getElementById("ddlSecurityQues").selectedIndex].value; if(value==9) { txtOwnQues.Visible = true; SetFocus(txtOwnQues); } else { txtOwnQues.Visible = false; SetFocus(txtAnswer); } } }

          Regards
          J O H N :rose:
          "Even eagles need a push." David McNally


          1 Reply Last reply
          0
          • P Priya S

            Html Side -------- asp:DropDownList ID="ddlSecurityQues" AutoPostBack="false" runat="server" Width="279px" OnSelectedIndexChanged="javascript:showownques();"> script ------ function showownques(value) { if(value==9) { txtOwnQues.Visible = true; SetFocus(txtOwnQues); } else { txtOwnQues.Visible = false; SetFocus(txtAnswer); } } } PROBLEM: not calling the function showonques(ddlSecurityQues.SelectedIndex)

            Thanks in advance, Priya.

            B Offline
            B Offline
            Brent Lamborn
            wrote on last edited by
            #5

            Did you do a View Source so see if the js call was added to your DDL? Try adding the Javascript in your code behind (like the pageload event) rather than in the aspx or ascx file. Using Atttributes.Add like this: ddlSecurityQues.Attributes.Add("onchange" , "showonques(this);") Then in your js function you can can get the selected index from the combo box passed into the function.


            "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups