Results 1 to 4 of 4
  1. #1

    Default Removing [brackets] from <input name="id[x]"

    Hi guys, quick question for someone who knows Zen a bit better than me.

    I need to remove the brackets from the input name generated by the attributes system.

    e.g.

    Code:
    <input name="id[2]"
    would become

    Code:
    <input name="id2"
    I've managed to get rid of the brackets by editing attributes.php, but this breaks the functionality of the attribute. Selecting the attribute before adding to cart results in no attribute ending up in the cart.

    I'm assuming I need to edit another file, but can't find what to change, or where.

    Please could somebody point me in the right direction! Many thanks..

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Removing [brackets] from <input name="id[x]"

    As you've said, removing the brackets creates a lot of trouble.
    So, the more important issue is your reason behind wanting to make the change.
    Thus, my reply to your post is .... Why?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3

    Default Re: Removing [brackets] from <input name="id[x]"

    I'm using the attribute form elements from the standard product info pages, to build a separate, custom form on another page.

    I'm using Javascript to change, show & hide elements of the custom form, depending on which other attributes are selected.

    The reason for removing the brackets is that one section of my custom form relies on a set of radio buttons controlling the contents of a dropdown menu below. Please see the except of code below to illustrate my problem, which is highlighted in red:

    Code:
    if(document.cart_quantity.id[2][0].checked==true)
    	{
    		locFrom.innerHTML='<select name="selectFrom" style="width:120px"><option value="test">Test</option></select>';
    		//document.write(locFrom.innerHTML);
    	}
    	if(document.cart_quantity.id[2][1].checked==true)
    	{
    		locFrom.innerHTML='<select name="selectFrom" style="width:120px"><option value="test2">Test2</option></select>';
    	}
    Javascript uses the numbers [0], [1], [2] etc after the input name to identify each radio button in the set - but the fact that id[2] also contains bracketed numbers breaks the form.

    I guess if it's not going to be possible to remove those brackets, I need to hit a Javascript forum instead!

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Removing [brackets] from <input name="id[x]"

    The brackets cause the value to be treated as an array, which is crucial for processing the selected options when the Submit button is pressed.

    I'm sure there will be other ways to process the information in your javascript. Perhaps you'll need to declare some other variables and stuff your information into them first, and then reference those variables with [0] or [1] etc appended to them. Or maybe lookup the object by name first, and reference those results instead.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 22
    Last Post: 12 Jan 2015, 09:45 PM
  2. v151 Removing "Featured" "New" Tabs Entirely From Index Page
    By dinohaven in forum General Questions
    Replies: 2
    Last Post: 4 Nov 2014, 03:33 PM
  3. I want to change sidebox title from "Manufactures" to "Magazine Name"
    By Golden Synergy in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 29 Aug 2010, 01:55 PM
  4. Removing "Units" and "Mix on/off" text from customer view?
    By InnaSky in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 8 Dec 2009, 08:31 PM
  5. Removing "Home" and "Login" from header.
    By damon.vit in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 6 Jan 2008, 12:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg