-
June 15th, 2011, 10:38 PM
#1
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.
-
June 17th, 2011, 10:28 AM
#2
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...
-
June 17th, 2011, 11:37 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|