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. can we set value of a text box from selection of items from the listbox by javascript

can we set value of a text box from selection of items from the listbox by javascript

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlquestion
2 Posts 2 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.
  • V Offline
    V Offline
    Vishnu Narayan Mishra
    wrote on last edited by
    #1

    Hi all, How can I set value of a text box from selection of items from the asp listbox or we can use any html control by javascript, since selectedIndex not working for the list box.. following is the code... ]]> State Management function ShowList() { document.getElementById('helptypediv').style.visibility='visible';return false; } function HideList() { document.getElementById('helptypediv').style.visibility='hidden';return false; } function ShowText() { var txtMessage = document.getElementById('lstShowHistory').options[selectedIndex].text; //Not Woking selectedIndex here document.getElementById('txtUrlLink').value = txtMessage; document.getElementById('helptypediv').style.visibility='hidden';return false; }

    <

    Url Name 1 Url Name 2 Url Name 3 <%-- Url Name 1 Url Name 2 Url Name 3 --%>

    C 1 Reply Last reply
    0
    • V Vishnu Narayan Mishra

      Hi all, How can I set value of a text box from selection of items from the asp listbox or we can use any html control by javascript, since selectedIndex not working for the list box.. following is the code... ]]> State Management function ShowList() { document.getElementById('helptypediv').style.visibility='visible';return false; } function HideList() { document.getElementById('helptypediv').style.visibility='hidden';return false; } function ShowText() { var txtMessage = document.getElementById('lstShowHistory').options[selectedIndex].text; //Not Woking selectedIndex here document.getElementById('txtUrlLink').value = txtMessage; document.getElementById('helptypediv').style.visibility='hidden';return false; }

      <

      Url Name 1 Url Name 2 Url Name 3 <%-- Url Name 1 Url Name 2 Url Name 3 --%>

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Vishnu Narayan Mishra wrote:

      'lstShowHistory'

      When working with ASP.NET, always look at the HTML source when something doesn't work. Even better, install Firefox and firebug, and debug your javascript in realtime. If these are server controls ( and if they are not, this belongs in the web dev forum ), if you look at your source, your service control called lstShowHistory is almost certainly not called that on the client. So, you need to inject javascript that creates variables that contain the client side Id's of these controls, then this sort of code will work.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      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