JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 1st, 2010, 11:53 AM
241 241 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 241 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 34 sec
Reputation Power: 0
PHP Drop Menu with onChange to populate hidden input prior to submit

I have the php code working to produce the drop menu and use the
Code:
onChange="flagmastcountryflag(this.value)"
to pass the value to javascript for process.
Code:
<?php
// Creates a pull-down list of flagmastcountries
  function get_flagmastcountry_list($name, $selected = '', $parameters) {
    $flagmastcountries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT_FLAGMASTCOUNTRY));
    $flagmastcountries = get_flagmastcountries();

    for ($i=0, $n=sizeof($flagmastcountries); $i<$n; $i++) {
      $flagmastcountries_array[] = array('id' => $flagmastcountries[$i]['countries_id'], 'text' => $flagmastcountries[$i]['countries_name']);
    }

    return draw_pull_down_menu($name, $flagmastcountries_array, $selected, $parameters);
  }

  function get_flagmastcountries($flagmastcountries_id = '', $with_iso_codes = true) {
    $flagmastcountries_array = array();

      $flagmastcountries = tep_db_query("select countries_id, countries_name from " . TABLE_FLAGMASTCOUNTRIES . " order by countries_name");
      while ($flagmastcountries_values = tep_db_fetch_array($flagmastcountries)) {
        $flagmastcountries_array[] = array('countries_id' => $flagmastcountries_values['countries_id'],
                                   'countries_name' => $flagmastcountries_values['countries_name']);

    }

    return $flagmastcountries_array;
    }
 	echo get_flagmastcountry_list('flagmastcountry','','onC  hange="flagmastcountryflag(this.value);"'); ?>


Which I then need to populate the hidden input field value
Code:
            $tmp_html = '<input type="hidden" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']]'">';

echo             '<td class="main">' . $tmp_html . '</td>';


I now have this for the javascript function
Code:
function flagmastcountryflag() {
  if(document.cart_quantity.flagmastcountry.options[0].value == true) {
    return false
  }
  else {
document.cart_quantity.idtxt_21.value=document.car  t_quantity.flagmastcountry.options[document.cart_quantity.flagmastcountry.selectedInd  ex].text;
  }
  return true;
}

this works provided I change the php side to give the input field name idtxt_21, however I need the name to be id[txt_21] for later in the php process.

How do I get the javascript to work using id[txt_21] instead of idtxt_21

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > PHP Drop Menu with onChange to populate hidden input prior to submit


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap