CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2011
    Location
    Bengaluru
    Posts
    6

    VB Script for dyanamically adding Combo box items in classic asp page

    Hi,

    I have two combo boxes,. txtconsol1 and txtconsol2.I want to write a VB script so that when the value of txtconsol1 changes, Items should be dynamically added to txtconsol2. For eg: if I selected india in txtconsol1, 27 states should be added dynamically to txtconsol2. How can i write a VB script for this.Please help.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB Script for dyanamically adding Combo box items in classic asp page

    On an ASP page? It would have to run on the server...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script for dyanamically adding Combo box items in classic asp page

    I have not did much in the way of client side VBScript but It should be possible. Almost certainly possible using javascript. You would need to have an ID for your combo that is to be updated and you would need a sub routine that fires when something is selected in the other combo that repopulates the target combo.

    Of course you can do this on the server side with ease all you need to do is have the combo submit the form with a different action tag and process that on the server then send back the page with the updated combos.

    Here is an example of how to make the form submit when the value of a combo is changed

    Code:
    <select name="jobid" onchange='this.form.submit()'>
    The form in question is defined here
    Code:
    <form name="addrow" action="etkmain.aspx?mode=add" method="post">
    Here is an example of how to change the action of the form.
    Code:
    <script type="text/javascript" language="javascript">
    	function addrowtodatabase()
    	{
    		
    		document.addrow.action='etkmain.aspx?mode=write';
    		return true;
    	}
    	
    
    
    </script>
    In the little examples above if the value in the combo is changed the form is submitted with the add code and if the sumbit button is clicked the function is called which changes the action code to write

    This is just one way this can be done. Then on the server side the code would need to send and updated page to the client.

    I do not do much web coding so I am far from an expert here but I would think with properly named forms and controls you could modify the lists on the client side if needed.
    Last edited by DataMiser; June 17th, 2011 at 11:42 AM.
    Always use [code][/code] tags when posting code.

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