Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

difficult to explain

Recommended Posts

This is a difficult question, it's too long of a story to explain so let me keep it simple.  You know how javascript can get an element information by id, or directly accessing it, well can that be done with php.  For instance, I have a get query coming to a page, and I have to populate a text field, It's ingraved deep within a system, it's zencart, so Idon'tknow where to find the system, so I was hoping I could put some code in another area, capture that get query, and put it into the text field, without directly putting <?php echo $_GET['variable']; ?> into the field area, is there a way to do this, at all?  in just php.

Share this post


Link to post
Share on other sites
See I have it doing everything I need, it's on a zencart shopping cart system.  I have it dynamically creating a url just fine, depending onw hat attributes were chosen, it creates a link and passes all item information over to a color pallete we create, they pick a color it passes all information back to the other page in a get query.  Thing is we need to get to the point were I can take one of the parameters returned from the get query to allow me to populate that text field, but that text field is heavily dynamically created on a page using a large number of various factors set in admin, so I have no direct access to the actual text field, none at all, I have to find a way to pop it in there anyway, and javascript, if they have it disabled, the whole system won't work properly.

Share this post


Link to post
Share on other sites
Prehaps you can insert the PHP code into the template as ZenCart appears to be using templates. I dont think Javascript can get URL parameters so you'll have to use PHP.

You might be better of getting help over at [url=http://www.zen-cart.com/forum/index.php]zen-cart.com[/url] forums. Also as ZenCart is a third party script I'll be be moving this to the Third Party PHP Scripts forum.

Share this post


Link to post
Share on other sites
Ok, I tried asking the zencart forums, they pointed me to the right files, I fixed the style issues, and worked up the system, but no-one as of yet has given me any advice on this so far.  The reason I am having a problem, is I am trying to figure out how to dynamically create it, anyone have any advice on this, I am working on both pages that have to do with the templates, that deals with attributes, the other page that dynamically creates them, I am a little scared to touch, the other page, is it possible to do that?  I need a general system because if may need to be replicated if we need to do it for more attributes later, to have a similar system.

Share this post


Link to post
Share on other sites
After doing some visual recon, I discovered how they set it up, they put each type of input into a different section, I found the one on text, I understand everything, because I know php now, but I am confused on how I could add it in for htat one type of text field, because later if we have another text type we need to fill with a specific value I am worried there might be problems, advice anyone, I found this by looking around?
[code]   
<?php
            // text
                  if (($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT)) {
                    //CLR 030714 Add logic for text option
                    //            $products_attribs_query = zen_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
                    //            $products_attribs_array = zen_db_fetch_array($products_attribs_query);
                    if ($_POST['id']) {
                      reset($_POST['id']);
                      foreach ($_POST['id'] as $key => $value) {
                        //echo ereg_replace('txt_', '', $key) . '#';
                        //print_r($_POST['id']);
                        //echo $products_options_names->fields['products_options_id'].'|';
                        //echo $value.'|';
                        //echo $products_options->fields['products_options_values_id'].'#';
                        if ((ereg_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'])) {
                          // use text area or input box based on setting of products_options_rows in the products_options table
                          if ( $products_options_names->fields['products_options_rows'] > 1) {
                            $tmp_html = '  <input disabled="disabled" type="text" name="remaining' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . '" size="3" maxlength="3" value="' . $products_options_names->fields['products_options_length'] . '" /> ' . TEXT_MAXIMUM_CHARACTERS_ALLOWED . '<br />';
                            $tmp_html .= '<textarea class="attribsTextarea" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" rows="' . $products_options_names->fields['products_options_rows'] . '" cols="' . $products_options_names->fields['products_options_size'] . '" onKeyDown="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" onKeyUp="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" >' . stripslashes($value) .'</textarea>' . "\n";
                          } else {
                            $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . stripslashes($value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';
                          }
                          $tmp_html .= $products_options_details;
                          break;
                        }
                      }
                    } else {
                      $tmp_value = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      // use text area or input box based on setting of products_options_rows in the products_options table
                      if ( $products_options_names->fields['products_options_rows'] > 1 ) {
                        $tmp_html = '  <input disabled="disabled" type="text" name="remaining' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . '" size="3" maxlength="3" value="' . $products_options_names->fields['products_options_length'] . '" /> ' . TEXT_MAXIMUM_CHARACTERS_ALLOWED . '<br />';
                        $tmp_html .= '<textarea class="attribsTextarea" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" rows="' . $products_options_names->fields['products_options_rows'] . '" cols="' . $products_options_names->fields['products_options_size'] . '" onkeydown="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" onkeyup="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" >' . stripslashes($tmp_value) .'</textarea>' . "\n";
                        //                $tmp_html .= '  <input type="reset">';
                      } else {
                        $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . htmlspecialchars($tmp_value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';
                      }
                      $tmp_html .= $products_options_details;
                      $tmp_word_cnt_string = '';
                      // calculate word charges
                      $tmp_word_cnt =0;
                      $tmp_word_cnt_string = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      $tmp_word_cnt = zen_get_word_count($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free']);
                      $tmp_word_price = zen_get_word_count_price($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free'], $products_options->fields['attributes_price_words']);

                      if ($products_options->fields['attributes_price_words'] != 0) {
                        $tmp_html .= TEXT_PER_WORD . $currencies->display_price($products_options->fields['attributes_price_words'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_words_free'] !=0 ? TEXT_WORDS_FREE . $products_options->fields['attributes_price_words_free'] : '');
                      }
                      if ($tmp_word_cnt != 0 and $tmp_word_price != 0) {
                        $tmp_word_price = $currencies->display_price($tmp_word_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
                        $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price;
                      }
                      // calculate letter charges
                      $tmp_letters_cnt =0;
                      $tmp_letters_cnt_string = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      $tmp_letters_cnt = zen_get_letters_count($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free']);
                      $tmp_letters_price = zen_get_letters_count_price($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free'], $products_options->fields['attributes_price_letters']);

                      if ($products_options->fields['attributes_price_letters'] != 0) {
                        $tmp_html .= TEXT_PER_LETTER . $currencies->display_price($products_options->fields['attributes_price_letters'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_letters_free'] !=0 ? TEXT_LETTERS_FREE . $products_options->fields['attributes_price_letters_free'] : '');
                      }
                      if ($tmp_letters_cnt != 0 and $tmp_letters_price != 0) {
                        $tmp_letters_price = $currencies->display_price($tmp_letters_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
                        $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price;
                      }
                      $tmp_html .= "\n";
                    }
                  }
?>
[/code]

Share this post


Link to post
Share on other sites
[code]<div class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsInput" for="attrib-60-285">Custom Laminate:</label></h4>
<div class="back"><input type="text" name="id[txt_60]" size="32" maxlength="32" value="" id="attrib-60-285" />[/code]

That is what the view source outputs, it outputs something a little different for each one, I am afraid if I change the wrong one, i only want a way to have it affect that one text box, that is why I was hoping to just throw it in there on the other page, without getting into that page, so I could replicate the process if we had to redo it for 4-5 different types of text inputs.

Share this post


Link to post
Share on other sites
My experience that I have had before, allowed me to complete this, I just redid some of the coding prehind the program, and it works now, thanks.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.