Product Templates - Adding an "onChange" field

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ryankivi1
Ensign (ENS)
Ensign (ENS)
Posts: 9
Joined: Tue May 06, 2008 3:00 pm

Product Templates - Adding an "onChange" field

Post by ryankivi1 » Tue May 20, 2008 1:20 pm

I'd like to be able to add a javascript call to some product templates. I see it already adds in the "id" field for accessing it with javascript.


Have this:
<select name="ctl00$wpm$ShowProduct$ctl07$InputField_23" id="ctl00_wpm_ShowProduct_ctl07_InputField_23">
Would like this:
<select name="ctl00$wpm$ShowProduct$ctl07$InputField_23" id="ctl00_wpm_ShowProduct_ctl07_InputField_23" onChange="DoSomething()">

Would this be done in one of the databases? I've been looking around and am a bit confused.

Thanks for any help.

Regards,

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Product Templates - Adding an "onChange" field

Post by jmestep » Tue May 20, 2008 2:38 pm

What display page are you working on?
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

ryankivi1
Ensign (ENS)
Ensign (ENS)
Posts: 9
Joined: Tue May 06, 2008 3:00 pm

Re: Product Templates - Adding an "onChange" field

Post by ryankivi1 » Tue May 20, 2008 3:33 pm

Judy,

Thank you for the post. Don't understand your question.

Regards,

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Product Templates - Adding an "onChange" field

Post by jmestep » Tue May 20, 2008 6:35 pm

Is this a display page for a product and if so, which. I just ran across something the other day that explained how you can put javascript on a asp control so it might help you if I can find the reference and you can tell me where you are trying to put it.
Last edited by jmestep on Tue May 20, 2008 6:37 pm, edited 1 time in total.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

ryankivi1
Ensign (ENS)
Ensign (ENS)
Posts: 9
Joined: Tue May 06, 2008 3:00 pm

Re: Product Templates - Adding an "onChange" field

Post by ryankivi1 » Tue May 20, 2008 6:36 pm

Yes its a product page for display/ordering.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Product Templates - Adding an "onChange" field

Post by jmestep » Tue May 20, 2008 6:37 pm

OK, now I'll try to find the code I read.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Product Templates - Adding an "onChange" field

Post by jmestep » Wed May 21, 2008 8:59 am

The code I was thinking of was for adding an onchange attribute to an html input tag in the code behind for a page.
I think what you want needs to be done in the App_Code/producthelper.cs. There is code there that handles an automatic post back for kit options and I think you can adapt it for the template fields code in the section above. Kit option code:

Code: Select all

public static List<int> BuildKitOptions(Product product, PlaceHolder phOptions)
    {
        List<int> selectedChoices = new List<int>();
        foreach (ProductKitComponent pkc in product.ProductKitComponents)
        {
            KitComponent component = pkc.KitComponent;
            if (component.InputType != KitInputType.IncludedHidden && component.KitProducts.Count > 0)
            {
                // CREATE A LABEL FOR THE ATTRIBUTE
                phOptions.Controls.Add(new LiteralControl("<tr><th class=\"rowHeader\">" + component.Name + ":</th>"));
                // ADD THE CONTROL TO THE PLACEHOLDER
                phOptions.Controls.Add(new LiteralControl("<td align=\"left\">"));
                WebControl o = component.GetControl();
                if (o != null)
                {
                    Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                    }
                    else if (oType.Equals(typeof(DropDownList)))
                    {
                        ((DropDownList)o).AutoPostBack = true;
                    }
                    else if (oType.Equals(typeof(CheckBoxList)))
                    {
                        ((CheckBoxList)o).AutoPostBack = true;
                    }
                    phOptions.Controls.Add(o);
                    // SEE WHETHER A VALID VALUE FOR THIS FIELD IS PRESENT IN FORM POST
                    List<int> theseOptions = component.GetControlValue(o);
                    selectedChoices.AddRange(theseOptions);
                }
                phOptions.Controls.Add(new LiteralControl("</td></tr>"));
            }
        }
        return selectedChoices;
    }
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply