Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:09:21+00:00 2026-06-07T12:09:21+00:00

javascript function test(abc) { var ddlArray = new Array(); var ddl = document.getElementById(‘AdjusterList’); for

  • 0

javascript

       function test(abc) {
         var ddlArray = new Array();
            var ddl = document.getElementById('AdjusterList');
          for (i = 0; i < ddl.options.length; i++) {
            ddlArray[i] = ddl.options[i].value;
          }
  var indexsel = ddl.selectedIndex;
      return indexsel ;            
     }

ASP

                 strArrayCRN = osRecordSet.RecordCount
                 strArrayCRN2 = osRecordSet2.RecordCount
                 dim StrCount 
                 StrCount =strArrayCRN+strArrayCRN2

HTML +ASP

<select name="AdjusterList" id="AdjusterList" onchange='test("<%=StrCount%>")'><%
%>
   <option value="0">Please choose an option from the list.</option>
  <% Do While (osRecordSet.EOF = False)
       %><option value="<%=osRecordSet.RowPosition%>">
          <%=osRecordSet.Fields("NAME")%></option>
      <%
     osRecordSet.MoveNext
      Loop        %><%
    Do While (osRecordSet2.EOF = False)
            %><option value="<%=osRecordSet2.RowPosition%>">
           <%=osRecordSet2.Fields("NAME")%></option>
       <%   osRecordSet2.MoveNext    Loop        %>

Here i want to pass the return value of function test() i.e value of the selected index to asp server side

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:09:24+00:00Added an answer on June 7, 2026 at 12:09 pm

    If you want to send it to server during normal html page submit, put the return value in hidden field.

    If you want to send the value before the form submit, use AJAX.

    Hidden Field method

    JavaScript

    function test(abc) {
             var ddlArray = new Array();
                var ddl = document.getElementById('AdjusterList');
              for (i = 0; i < ddl.options.length; i++) {
                ddlArray[i] = ddl.options[i].value;
              }
      var indexsel = ddl.selectedIndex;
          document.getElementById("returnValueField").value = indexsel;
          return indexsel ;            
         }
    

    HTML

    <input type="hidden" id="returnValueField" name="returnValueField" />
    

    In ASP access this hidden field like an other form field.

    For AJAX use some library like jQuery to make things easier.

    Using AJAX with jQuery

    First you need to include the jQuery library in your page.

    Then modify your function like this

    function test(abc) {
                 var ddlArray = new Array();
                    var ddl = document.getElementById('AdjusterList');
                  for (i = 0; i < ddl.options.length; i++) {
                    ddlArray[i] = ddl.options[i].value;
                  }
          var indexsel = ddl.selectedIndex;
              // Ajax call starts
              $.ajax({
                     url: "your_asp_page_to_handle_request.asp",
                     data: {"selected_index": indexsel },
                     success: function() { 
                        alert("I am back after sending data sucessfully to server.");}
                     });
              // Ajax call ends  
    
              return indexsel ;            
             }
    

    Your ASP code in your_asp_page_to_handle_request.asp will be something like this

    <%
    
    dim selectedIndex
    selectedIndex = Request.QueryString("selected_index")
    
    %>
    

    Please note that you can also use jQuery.get() instead of the Ajax function we used above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider we have a simple cycling Javascript process as: function test() { el=document.getElementById("test"); var
Classic javascript: var myvar = document.getElementById(abc); abc.value += test; abc.value += another test; Jquery:
My javascript: function onYouTubePlayerReady() { playerObj = document.getElementById(player_embed); playerObj.addEventListener(onStateChange, test); // Make sure the
I am trying to sort a table with JavaScript. function test() { var table
Sample code: <!DOCTYPE html> <html> <head> <title>test</title> <script language=javascript type=text/javascript> function init() { var
Hi i have this javascript function function test(){ var count = 0; var date1
Suppose I have a long javascript function such as function test() { var x;
I have a function in javascript: function test(){ ... if (){ setTimeout(test(), 1000); }
Page1 : test.php (open in popup) <script type=text/javascript> function addFiles(aFiles) { if ($('#addfiles').length==0) $('#addfiles').html;
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.