Post by gartheman » Wed Apr 10, 2013 5:09 am

Hey there,

I'm wondering how I can set my 'textarea' option to be inactive by default, and only go active if another option 'yes/no' is set to yes? I want customers to be able to add their text for a product, but only if they have selected the correct option, otherwise the 'textarea' won't allow them to add anything.

This topic seems to explain something similar, but for a checkbox system
http://forum.opencart.com/viewtopic.php?t=81006

I'm using OC 1.5.4

Thanks for reading

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by gartheman » Sat Apr 13, 2013 6:44 am

also, if I do find the solution, which file should it be added to??

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by gartheman » Sun Apr 14, 2013 7:23 pm

thanks for that. i'm trying to get my head around this issue, and I know what i'm looking for is contained in those two threads. the problem is i'm not sure where opencart stores options once created in the admin backend. once I know where the options are stored i'll be able to find the variable names and edit the code to suit what I need (i hope!)

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by butte » Mon Apr 15, 2013 6:36 am

What I had in mind isn't here, so either I hadn't actually typed it or it didn't "take" and I'll (re)do it.

You can grab a backup of the database (Systems / Backup), make a backup of that (against inadvertence), and open it in a pure text editor or (after renaming it .csv) a spreadsheet, or open it in something like either phpMyAdmin in the server's control panel or Oracle's Workbench on your own machine, and look (using Find) for options by names you remember or via OC admin panel can see. Inside that zoo you can probably relate those to machine-readable variables and definitions, which will tell you where to trigger the desired effect. Meanwhile, look at product. files, both .tpl and .php, in the subtrees where they appear. You should find the variable names and the appropriate files in fairly short order.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by gartheman » Mon Apr 15, 2013 5:30 pm

well what I usually do is open any files (in this case 'product.tpl and product.php) I need to edit in Notepad++. here I can usually use FIND to locate what I need and then tailor my code accordingly. i think my problem is the way opencart creates and names options. when I use google chrome to analyse the options in a browser setting, the variable/option will have a name of something like 'option[229]', which I believe is one option of an array of options. therefore I'm not sure how I can have the javascript just applied to this option and not all options??

i hope that makes sense, and i'll report back if I make any progress

as an aside, this site is still a work in progress, using XAMPP to allow opencart to run locally, so atm I can't link to any live pages (yet anyway)

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by butte » Tue Apr 16, 2013 8:07 am

Where a textarea is already sitting there static, the options will presumably be above it, and if-then looking at the options set can be made to trigger the textarea. You'll find relationships among a 3-digit number, a $ value, and places where "variable" show up (defining terms, for example). The database cross-references those, just (I know, at this stage "just" isn't yet happening) Find columns (fields) and rows (records) where they intersect.

A simpler interim way is to set a checkbox in place, then use the state of that to trigger textarea (an admonition not to use it unless options are already entered would be respected at least some of the time).

For example, selectable sizes, little, small, medium, large, extra large, extra-extra large, huge, enormous, with "check this for details or comment," could open a box where a customer could note that husband or son is probably enormous, but please choose whichever size will fit, he stands 8'11" and weights 450 lbs.. You wouldn't likely be keeping utterly-enormous on hand but could have it tailored.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am
Who is online

Users browsing this forum: Semrush [Bot] and 213 guests