Results 1 to 4 of 4

Thread: JavaScript question...simple to anyone who know JS

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    JavaScript question...simple to anyone who know JS

    I have a function:
    Code:
    function RebuildStartTimeDropDownCallBack()
    	{
    		var StartTimeIndex = document.main.StartTime.selectedIndex
                              'do some code
    		document.main.StartTime.selectedIndex = StartTimeIndex
    	}
    However, I don't want to store, and restore the index.
    I'd like to get the item data, and then select the combo item that has the same item data that I stored after I have done "Some other code". Item data is unique from a DB (Primary key ID)

    Woka

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: JavaScript question...simple to anyone who know JS

    Urgh I dont know any JS but I'll try to help

    Could you maybe do this
    Code:
    function RebuildStartTimeDropDownCallBack()
    	{
                    var StartTimeData = document.main.StartTime.value
                              'do some code
                    for (i=0, document.main.StartTime.length, i++) //Dunno about the .length
                        if (document.main.StartTime.thing[i] == StartTimeData) {
                            /* The .thing obviously you replace with whatever the JS
                                equivalent of VB's .List(i) would be */
    		        document.main.StartTime.selectedIndex = i
                        }
                    }
    	}
    ? I know thats probably useless, I'm no good with Javascript.

  3. #3
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: JavaScript question...simple to anyone who know JS

    Code:
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title></title>
      <script>
      function changeIt(){
        //select the item with option value of 3 ie this will be you DB PK
        document.frm.sel.options.value = 3;
      }
      </script>
      </head>
      <body>
      <form name="frm">
        <select name="sel">
          <option value="1">one</option>
          <option value="2">two</option>
          <option value="3">three</option>
          <option value="4">four</option>
          <option value="5">five</option>
        </select>
        <input type="button" value="click" onclick="changeIt();">
      </body>
    </html>
    Edit:
    bugger need to try again that dosn't work with firefox.

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: JavaScript question...simple to anyone who know JS

    ok dokey this seems to work in both (if this is what your looking for not entirely sure)
    Code:
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title></title>
      <script>
      function changeIt(){
        //select item with option value of c
        document.frm.sel.value = "c";
      }
      </script>
      </head>
      <body>
      <form name="frm">
        <select name="sel">
          <option value="a">one</option>
          <option value="b">two</option>
          <option value="c">three</option>
          <option value="d">four</option>
          <option value="e">five</option>
        </select>
        <input type="button" value="click" onclick="changeIt();">
      </body>
    </html>

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