0

So I have an .aspx page loading up and populating drop downs based on a lookup table in the database. What we want is for the user to be able to configure which of these values comes defaulted by specifying that value in a drop down somewhere else in the app.

Now, it's easy to default the "first" value, or something like that, but we want this to act differently. Is there a JavaScript function that can run immediately after onLoad (so the drop downs are populated already), that can go through the drop down and make one of those default so it looks like the page is loading with that set as default and people don't realize the workaround? (weird masking, etc.)

I'm not TOO experienced with JavaScript so something like this may already exist.

Here is an example of how we add the dropdown control to the page, in case you guys even need that.

With CType(.AddControl(New Controls.ComboBox("CodeId", "../../../../CodeId", "Code")), Controls.ComboBox)
                            .ForceSelection = True
                            .ValueField = "LookupID"
                            .DisplayField = "LookupDesc"
                            .Validate.AllowBlank = False
                            .ForceSelection = True
                            .ReadOnly = EditControl.IsFieldReadOnly(10580)
                            .BindData(Model.Codes)
                        End With 

Thanks guys!

-Scott

1
  • That's where the data is stored that populates the control, and I thought one possible solution might have to do with an added proc in the database to store an order by using a defaulted value, so I wanted to get a SQL guy possibly in here that might think about that.
    – Scott
    Sep 8, 2010 at 13:40

2 Answers 2

3

Since you are using ExtJs you can do something like:

Ext.onReady(function(){

   //place your code here

});

This may solve your problem

1

You need an onReady event, like what jQuery provides: http://api.jquery.com/ready/. It will run when the page content is ready to be manipulated.

2
  • We run everything in ExtJS at the moment. Is there anything that comes with Ext that is similar? Or anything in basic Javascript that would work the same way?
    – Scott
    Sep 7, 2010 at 20:44
  • See what @João Gala Louros posted Sep 7, 2010 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.