Link to home
Start Free TrialLog in
Avatar of OmniUnlimited
OmniUnlimitedFlag for United States of America

asked on

Set Javascript Multidimensional Array with PHP Foreach Function

Hello experts,
I've got a problem that has me stumped.  I would like to transfer a multidimensional array from PHP to Javascript using the foreach loop along the lines of what I wrote down in the code below, but I can't get it to work.  Can anyone assist me?

($form_data is the result of a query to a table)

And, if you know of a way to get this to work, would you also know of a way that I could iterate the assignments, along the line of:

<?php foreach($form_data as $key => $form_field) {
                 foreach($form_field as $key2 => $value) {
             echo "form_field[$key][$key2] = $value;";
      }
              }?>

(Please don't criticize the code if this is completely wrong.  I seriously don't know what I am doing here.)
?>
<script type="text/javascript">
     jQuery(document).ready( function () {
          jQuery('input').bind('keyup change', function () {	
               if(this.name.indexOf('collected_data') == -1) {
	if(jQuery('input[name="same_address"]').attr('checked') == true) {
	      var form_field = [];
	<?php foreach($form_data as $form_field) {
	       echo "form_field['id'] = $form_field['id'];";
	       echo "form_field['name'] = $form_field['name'];";
	       echo "form_field['type'] = $form_field['type'];";
	} ?>
               }
          } else {
                jQuery('input[name="same_address"]').attr('checked', false);
          }
     });
});
</script>
<?php

Open in new window

Avatar of profya
profya
Flag of Sudan image

Try changing this:
              echo "form_field['id'] = $form_field['id'];";
               echo "form_field['name'] = $form_field['name'];";
               echo "form_field['type'] = $form_field['type'];";

To
              echo "form_field['id'] = $form_field['id'];\n";
               echo "form_field['name'] = $form_field['name'];\n";
               echo "form_field['type'] = $form_field['type'];\n";

Adding new line at the end.
Try doing the same thing. I would like to ask, do you get javascript errors? What error if any.
<?php foreach($form_data as $key => $form_field) {
                 foreach($form_field as $key2 => $value) {
             echo "form_field[$key][$key2] = $value;\n";
      }
              }?>

Open in new window

Avatar of OmniUnlimited

ASKER

Hello profya, many thanks for your input.  I tried both of your suggestions.  On the first, I get a

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home4/sleepama/public_html/wp-content/plugins/wp-e-commerce/edit-profile.php on line 144

Line 144 is            
echo "form_field['id'] = $form_field['id'];\n";

The second did not work.  I even tried sticking in an echo "alert(form_field[$key][$key2]);\n"; to see if the variables were taking and I got no alert box.

Avatar of hielo
try:
?>
<script type="text/javascript">
     jQuery(document).ready( function () {
          jQuery('input').bind('keyup change', function () {    
               if(this.name.indexOf('collected_data') == -1) {
        if(jQuery('input[name="same_address"]').attr('checked') == true) {
              var form_field = [];
        <?php foreach($form_data as $key =>$value) {
               echo "form_field['{$key}'] = {$value};";
        } ?>
               }
          } else {
                jQuery('input[name="same_address"]').attr('checked', false);
          }
     });
});
</script>
<?php

Open in new window

NOTE:
echo "form_field['{$key}'] = {$value};";

will work fine if $value contains numbers only. Otherwise use:
echo "form_field['{$key}'] = '{$value}';";
hielo, you are definitely on to something here.  I was able to verify that arguments are being passed to javascript through your coding, however $value is an array (formerly $form_field in my previous coding).  How do I separate out the elements?
I copied from your code, I didn't notice there is a missing double quote:

              echo "form_field['id'] = "$form_field['id'];\n";
               echo "form_field['name'] = "$form_field['name'];\n";
               echo "form_field['type'] = "$form_field['type'];\n";

Open in new window

Sorry again:
              echo "form_field['id'] = ".$form_field['id']".;\n";
               echo "form_field['name'] =". $form_field['name'].";\n";
               echo "form_field['type'] = ".$form_field['type'].";\n";

Open in new window

If I understand you correctly form_field['id'] should be initialized to an array of values?
If yes try:

echo "form_field['{$key}'] = ['" . implode("','",$value) . "'];";

Open in new window

And this is the second foreach code:
<?php 
foreach($form_data as $key => $form_field) {
	foreach($form_field as $key2 => $value) {
		echo "form_field['".$key2."'] = ".$value.";\n";
      }
}?>

Open in new window

Originally you posted:
"($form_data is the result of a query to a table)" and now you are saying "$value is an array (formerly $form_field in my previous coding)". How did you get an $form_field to be an array from a db table query???

Are you trying to do a JAVASCRIPT multi-dimentional Array?
Like:
form_data[0]['id']="..."
form_data[0]['name']="..."
form_data[1]['id']="..."
form_data[2]['name']="..."
etc?

If yes, try:
 <?php foreach($form_data as $value) {
 			foreach($value as $k=>$v){
               	echo "form_field[form_field.length]['{$k}'] = '{$value}';";
			}
        } ?>

Open in new window

No, actually, the final result I would want form_field['id'] to contain a single string value.  What is happening is that $form_data is coming as a result from a table query and has rows of fields in it.  Using the foreach statement in PHP, I am able to separate each row into an array called $form_field, by which I can access the individual fields by plugging in the field name, such as $form_field['id'].  I want this same capability in javascript.
Thank you hielo, what you described in your last comment is absolutely correct.  However, I tried your code and it did not work.
sorry, on my last post:
 '{$value}'

should be:
 '{$v}'
echo "form_field[form_field.length]['{$k}'] = '{$v}';";
I am inserting an echo "alert(form_field[form_field.length]['{$k}']);"; right after your last line of code to see what the values are, and I am getting no alert box.
On line 8 of your original post, change:
<?php foreach($form_data as $form_field) {
 
to:
<?php       var_dump($form_data);
            foreach($form_data as $form_field) {
 
then reload your page and view the browser's source code. What does that line give you? Copy it and paste it here!

Open in new window

I suspect that in this:

foreach($form_data as $form_field)
 
$form_data is ONE row from your query, probably something like:
 
$result=mysql_query("SELECT ....") or die( mysql_error());
while( $form_data=mysql_fetch_assoc($result) ){
 
  /* at this point $form_data contains one row of data, but when you do your foreach($form_data as $form_field){...}, $form_fields is NOT an array, in which case what you need is:*/
 
  foreach($form_data as $key=>$form_field)
  {
   echo "form_field[form_field.length]['{$key}']='{$form_field}';";
  }
}

Open in new window

hielo, I get a

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home4/sleepama/public_html/wp-content/plugins/wp-e-commerce/edit-profile.php on line 147

with line 147 as
             echo "form_field['id'] = $form_field['id'];";

profya:  Thank you for your input.  Unfortunately, your coding did not work either.
hielo, I was able to verify through an alert placed on your former coding that $form_field is an array containing the fields 'id', 'name', 'type', 'mandatory', etc.
ASKER CERTIFIED SOLUTION
Avatar of profya
profya
Flag of Sudan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>I am inserting an echo "alert(form_field[form_field.length]['{$k}']);"; right after your last line of code to see what the values are, and I am getting no alert box.
That alert() should use form_field.length MINUS 1

alert( form_field[ form_field.length-1]['id'] );

What do you have now? Open your page through Firefox and click on View > Source and paste the output of your script here. I have 1 more minute to spare.
got to go. Hope attached code helps:
<?php 
foreach($form_data as $form_field) {
    foreach($form_field as $k=>$v){
      echo "form_field[form_field.length]['{$k}'] = '{$v}';";
      echo "alert( form_field[form_field.length-1]['{$k}'] );";
    }
} 
?>

Open in new window

hielo, I did as you requested.  Still no alert box.  My page is rather complicated, but if you want to see the source code from the browser, here it is.

profya, give me a minute to try your coding.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
 
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="verify-v1" content="QhoLkdDS4dbqMy7lO0l2Cr+2z2ALZ8gJKSXn8C56nFw=" >
<title>Your Account &laquo;  Sleep Amazing</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
 
<link rel="stylesheet" href="https://sleepamazing.com/wp-content/themes/commercial/style.css" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="Sleep Amazing RSS Feed" href="http://sleepamazing.com/?feed=rss2" />
<link rel="alternate" type="application/atom+xml" title="Sleep Amazing Atom Feed" href="http://sleepamazing.com/?feed=atom" />
<link rel="pingback" href="http://sleepamazing.com/xmlrpc.php" />
 
<script src="../../../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="../../../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<script src="../../../SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="../../../SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script src="../../../wp-includes/js/user.js" type="text/javascript"></script>
 
<link rel='stylesheet' href='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/themes/default/default.css?ver=3.7.8' type='text/css' media='all' />
<link rel='stylesheet' href='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/themes/compatibility.css?ver=3.7.8' type='text/css' media='all' />
<link rel='stylesheet' href='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/product_rater.css?ver=3.7.8' type='text/css' media='all' />
<link rel='stylesheet' href='https://sleepamazing.com/index.php?wpsc_user_dynamic_css=true&#038;category&#038;ver=3.7.8' type='text/css' media='all' />
<link rel='stylesheet' href='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/thickbox.css?ver=3.7.8' type='text/css' media='all' />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://sleepamazing.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://sleepamazing.com/wp-includes/wlwmanifest.xml" /> 
<script type='text/javascript' src='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/js/jquery.js?ver=1.2.3'></script>
 
<script type='text/javascript' src='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/js/thickbox.js?ver=Instinct_e-commerce'></script>
<script type='text/javascript' src='https://sleepamazing.com/wp-includes/js/jquery/jquery.js?ver=1.2.6'></script>
<script type='text/javascript' src='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/js/wp-e-commerce.js?ver=3.78'></script>
<script type='text/javascript' src='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/ajax.js?ver=3.78'></script>
<script type='text/javascript' src='https://sleepamazing.com/index.php?wpsc_user_dynamic_js=true&#038;ver=3.7.8'></script>
<script type='text/javascript' src='http://sleepamazing.com/wp-content/plugins/wp-e-commerce/user.js?ver=3.78'></script>
<script type='text/javascript' src='https://sleepamazing.com/wp-includes/js/comment-reply.js?ver=20081210'></script>
<meta name="generator" content="WordPress 2.7.1" />
 
<link rel='alternate' type='application/rss+xml' title='Sleep Amazing Product List RSS' href='http://sleepamazing.com/index.php?rss=true&amp;action=product_list'/><link rel="stylesheet" type="text/css" href="http://sleepamazing.com/wp-content/plugins/wp-recaptcha/recaptcha.css" /></head>
 
<body>
<div id="page">
	<div id="header">
	    <div id="hdrcol1">
    		<div id="logocaption">
            	<div id="logoimage">
                	<a href="http://sleepamazing.com"><img src="https://sleepamazing.com/wp-content/themes/commercial/images/sleepamazing_logo.gif" alt="Sleep Amazing" border="0" /></a>
            		<!-- original coding
					<div id="sitename"><a href="http://sleepamazing.com">Sleep Amazing</a></div>
					<div id="tagline"><a href="http://omniunlimited.com">An Omni Unlimited Company</a></div>
                    -->
                </div>
    		</div>
 
        </div>
		<div id="hdrcol2">
        </div>
        <div id="hdrcol3">
			<div id="usefullinks">
    	<table class="linktable">
		<tr class="spacerrow">
    		<th>&nbsp;</th>
    		<th>&nbsp;</th>
 
    		<th>&nbsp;</th>
    		<th>&nbsp;</th>
            <th id="shopicon" rowspan="3">
            	<table class="shopcarttext">
                	<tr>
            			<th id="shopcartlabel">Cart:</th>
                		<th id="shopcartitems"><a href="https://sleepamazing.com/?page_id=4">0 items</a></th>
              		</tr>
 
                </table>
             </th>
  		</tr>
    	<tr>
        	<td><a href="https://sleepamazing.com/?page_id=681&edit_profile=true&shipping=true&logout=true&action=logout">Sign Out</a></td>
            <td><a href="http://sleepamazing.com/?page_id=82"> Help </a></td>
            <td><a href="https://sleepamazing.com/?page_id=681"> Account </a></td>
 
            <th id="orderlabel"><a href="https://sleepamazing.com/?page_id=681&order_history=true"> Order Status </a></th>
        </tr>
		<tr class="spacerrow">
    		<th id="tollfree" colspan="4">Call Us at 1-877-250-OMNI (6664)</th>
        </tr>
        </table>
			</div>
 
		</div>
	<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
		<ul id="MenuBar1" class="MenuBarHorizontal">
  <li><a class="MenuBarItemSubmenu" href="http://sleepamazing.com">Home</a></li>
  <li><a class="MenuBarItemSubmenu" href="http://sleepamazing.com/?page_id=2">About Us</a></li>
  <li><a class="MenuBarItemSubmenu" href="http://sleepamazing.com/?page_id=179">Products</a>
      <ul class="ProductMenu">
 
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=3&category=14">Air Suspension</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=3&category=17">Latex Foam</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=3&category=16">Memory Foam</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=3&category=18">Innerspring</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=3&category=15">Water Beds</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=200">Bedroom Furniture</a></li>
 
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=205">Accessories</a></li>
      </ul>
  </li>
  <li><a class="MenuBarItemSubmenu" href="http://sleepamazing.com/?page_id=22">Information</a>
      <ul class="InformationMenu">
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=139">Digital Air Inflator Comparison</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=224">Bamboo</a></div></div></li>
 
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=145">Digital Sleep Air Chamber Comparison</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=269">Memory Foam</a></div></div></li>
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=149">Precision Control in mm/Hg</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=300">Waterbeds</a></div></div></li>
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=152">Effects of Pressure of Circulation</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=337">Innersprings</a></div></div></li>
 
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=95">Cool Plus&reg;</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=317">Adjustable Foundations</a></div></div></li>
        <li><div class="divContainer"><div class="MenuCol1"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=15">Talalay Latex</a></div>
        <div class="MenuCol2"><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=107">Scape Remote</a></div></div></li>
      </ul>
  </li>
  <li><a class="MenuBarItemSubmenu" href="http://sleepamazing.com/?cat=4">News</a></li>
 
  <li><a class="MenuBarItem" href="http://sleepamazing.com/?page_id=7">Community</a>
  	  <ul class="CommunityMenu">
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/phpBB3/">Forums</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/phpBB3/viewforum.php?f=4">Testimonies</a></li>
      </ul>
  </li>
  <li><a class="MenuBarItem" href="http://sleepamazing.com/?page_id=26">Contact Us</a>
 
  	  <ul class="ContactUsMenu">
        <li><a id="_lpChatBtn1" class="MenuBarLevel2" href='https://server.iad.liveperson.net/hc/6461214/?cmd=file&file=visitorWantsToChat&site=6461214&byhref=1&SESSIONVAR!skill=Customer%20Service&imageUrl=https://images.liveperson.com/lp/6461214' target='chat6461214'  onclick="lpButtonCTTUrl = 'https://server.iad.liveperson.net/hc/6461214/?cmd=file&file=visitorWantsToChat&site=6461214&SESSIONVAR!skill=Customer%20Service&imageUrl=https://images.liveperson.com/lp/6461214&referrer='+escape(document.location); lpButtonCTTUrl = (typeof(lpAppendVisitorCookies) != 'undefined' ? lpAppendVisitorCookies(lpButtonCTTUrl) : lpButtonCTTUrl); lpButtonCTTUrl = ((typeof(lpMTag)!='undefined' && typeof(lpMTag.addFirstPartyCookies)!='undefined')?lpMTag.addFirstPartyCookies(lpButtonCTTUrl):lpButtonCTTUrl);window.open(lpButtonCTTUrl,'chat6461214','width=475,height=400,resizable=yes');return false;" >Live Chat</a></li>
        <li><a class="MenuBarLevel2" href="http://sleepamazing.com/?page_id=37">E-mail</a></li>
      </ul>
  </li>
</ul>
 
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../../../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../../../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
 
<div id="searchformarea"><div id="adline"></div><div id="search_form"><form action="http://sleepamazing.com/searchresults.php" id="cse-search-box">
  	<div>
    <input type="hidden" name="cx" value="partner-pub-9272638677950417:ujk26wnnq0y" />
    <input type="hidden" name="cof" value="FORID:10" />
    <input type="hidden" name="ie" value="UTF-8" />
	<div id="searchcontainer"><div id="searchfield"><input type="text" value="" name="q" id="s" /></div>
    <div id="searchbtn"><input type="image" src="https://sleepamazing.com/wp-content/themes/commercial/images/search-button-red.gif" name="sa" id="searchsubmit" /></div>
  	</div></div>
	</form>
 
	<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script></div></div>
	<div id="headerimg">
	</div>
</div>
<hr />
<div id="wrapper">
 
<div class="breadcrumb"><!-- Breadcrumb NavXT 3.2.1 -->
<a title="Go to Home." href="http://sleepamazing.com">Home</a> &gt; <a title="Go to Categories." href="http://sleepamazing.com/?page_id=179">Categories</a> &gt; <a title="Go to Products Page." href="http://sleepamazing.com/?page_id=3">Products Page</a> &gt; <span class="current">Your Account</span></div>	<div id="content" class="narrowcolumn">
 
				<div class="post" id="post-681">
				<h4>Your Account</h4>
        			<div class="entry">
				<div class="wrap" style=''>
 <div class='user-profile-links'><a href='https://sleepamazing.com/?page_id=681'>Account</a> | <a href='https://sleepamazing.com/?page_id=681&profile=true'>Profile</a> | <a href='https://sleepamazing.com/?page_id=681&order_history=true'>Order History</a></div><br /><br /><form method='POST'>
 
<div id="billship_bg" class="t"><div class="b"><div class="l"><div class="r"><div class="bl25g"><div class="br25g"><div class="tl25g"><div class="tr25g">
<div class="billship_row"><div class="billship_col1">
	<script type="text/javascript">
		jQuery(document).ready( function () {
 
	 		jQuery('input').bind('keyup change', function () {	
				if(this.name.indexOf('collected_data') == -1) {
					if(jQuery('input[name="same_address"]').attr('checked') == true) {
	      var form_field = [];
form_field[form_field.length]['id'] = '1';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = '1. Billing Information';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'heading';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '1';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '2';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'First Name';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'firstname';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '1';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '2';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '3';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Last Name';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'lastname';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '1';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '3';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '4';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Company';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'company';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '4';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '5';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Address';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'address';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '5';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '6';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'City';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'city';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '6';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '7';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'State';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'state';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '7';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '8';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Country';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'country';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '8';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '9';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Postal Code';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'postal_code';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '9';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '10';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Phone';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'phone';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '10';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '11';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Email';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'email';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '1';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '1';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '11';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '12';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = '2. Shipping Information';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'heading';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '12';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '13';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'First Name';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_firstname';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '13';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '14';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Last Name';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_lastname';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '14';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '15';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Company';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_company';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '15';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '16';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Address';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_address';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '16';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '17';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'City';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_city';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '17';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '18';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'State';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_state';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '18';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '19';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Country';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_country';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '19';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '20';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Postal Code';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_postal_code';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '20';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '21';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Phone';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_phone';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '21';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);form_field[form_field.length]['id'] = '22';alert(form_field[form_field.length-1]['id']);form_field[form_field.length]['name'] = 'Email';alert(form_field[form_field.length-1]['name']);form_field[form_field.length]['type'] = 'delivery_email';alert(form_field[form_field.length-1]['type']);form_field[form_field.length]['mandatory'] = '0';alert(form_field[form_field.length-1]['mandatory']);form_field[form_field.length]['display_log'] = '0';alert(form_field[form_field.length-1]['display_log']);form_field[form_field.length]['default'] = '';alert(form_field[form_field.length-1]['default']);form_field[form_field.length]['active'] = '1';alert(form_field[form_field.length-1]['active']);form_field[form_field.length]['order'] = '22';alert(form_field[form_field.length-1]['order']);form_field[form_field.length]['unique_name'] = '';alert(form_field[form_field.length-1]['unique_name']);              			// set field values
						// jQuery('input[name="collected_data[15]"]').attr('value', 'Omni Unlimited');
					}
				} else {
					jQuery('input[name="same_address"]').attr('checked', false);
				}
			});
 
		});
	</script>
<table cellpadding=0 cellspacing=0><tr><td width='190px'><strong>Shipping Information</strong></td><td valign='top' width='25px'><input type='checkbox' name='same_address' style='width:15px;' /></td><td>Check if same as billing address.</td></tr></table><table class='checkout_form'>
 
<tr>
  <td colspan='2' style='padding: 0px;'>
 
<span class='red'></span>
  </td>
</tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='George' name='collected_data[2]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='Washington' name='collected_data[3]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='' name='collected_data[4]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='1600 Pennsylvania Avenue NW' name='collected_data[5]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='Washington' name='collected_data[6]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='' name='collected_data[7]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='20500' name='collected_data[9]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='(202) 456-1111' name='collected_data[10]' />
          </td>
        </tr>
 
<tr style='display: none;'><td colspan='2' align='left'><input type='hidden' value='president@whitehouse.gov' name='collected_data[11]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
First Name
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='George' name='collected_data[13]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Last Name
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='Washington' name='collected_data[14]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Company
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='' name='collected_data[15]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Address
          </td>
 
          <td  align='left'>
 
<textarea class='normalize_font' name='collected_data[16]'>1600 Pennsylvania Avenue NW</textarea>
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
City
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='Washington' name='collected_data[17]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
State
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='DC' name='collected_data[18]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Postal Code
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='20500' name='collected_data[20]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Phone
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='(202) 456-1111' name='collected_data[21]' />
          </td>
        </tr>
 
        <tr>
          <td align='left'>
 
Email
          </td>
 
          <td  align='left'>
 
<input class='normalize_font' type='text' value='president@whitehouse.gov' name='collected_data[22]' />
          </td>
        </tr>
 
        <tr style='display: none;'>
      <td>
      </td>
      <td>
      <input type='hidden' value='true' name='submitwpcheckout_profile' />
      </td>
    </tr>
</table>
</div><div class="billship_col2">
 
<div class="billship_submit">
<input type='image' name='submit' src='https://sleepamazing.com/wp-content/themes/commercial/images/save_profile_gbg.gif' alt='Save Profile' style='margin-top: 215px;' /></div>
</div></div>
</div></div></div></div></div></div></div></div>
</form>
	</div>
 
 
 
				
			</div>
		</div>
				</div>
 
	<div id="sidebar">
		<ul>
			<li id="wpsc_categorisation-382640071" class="widget widget_wpsc_categorisation"><div id='categorisation_group_4'>
 
<h2 class='categorytitle'>Bedroom Furniture</h2>
 
<div class='PeSwitcher'></div><div class='PeCatsBrands'><div class='PeCategories categorydisplay'><ul class='PeCategories'><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=19'>Collections</a></span></li></ul></div></div>
 
</div>
 
<div id='categorisation_group_3'>
 
<h2 class='categorytitle'>Mattresses</h2>
 
<div class='PeSwitcher'></div><div class='PeCatsBrands'><div class='PeCategories categorydisplay'><ul class='PeCategories'><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=14'>Air Suspension</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=18'>Innerspring Support</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=17'>Latex Foam</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=16'>Memory Foam</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=15'>Water Beds</a></span></li></ul></div></div>
 
</div>
 
<div id='categorisation_group_1'>
 
<h2 class='categorytitle'>Accessories</h2>
 
<div class='PeSwitcher'></div><div class='PeCatsBrands'><div class='PeCategories categorydisplay'><ul class='PeCategories'><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=9'>Mattress Pads</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=20'>Miscellaneous</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=11'>Pillows</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=8'>Sheets & Comforters</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=10'>Toppers</a></span></li></ul></div></div>
 
</div>
 
<div id='categorisation_group_2'>
 
<h2 class='categorytitle'>Brands</h2>
 
<div class='PeSwitcher'></div><div class='PeCatsBrands'><div class='PeCategories categorydisplay'><ul class='PeCategories'><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=12'>Bebe</a></span></li><li class='MainCategory'><span class='category'><a class='productlink' href='http://sleepamazing.com/?page_id=3&amp;category=4'>Comfort Line</a></span></li></ul></div></div>
 
</div>
 
</li><li id="price-range" class="widget widget_price_range"><h2 class="widgettitle">Price Range</h2><ul><li class='MainCategory'><a href='http://sleepamazing.com/?page_id=3&range=1'>Over 0</a></li><li class='MainCategory'><a href='http://sleepamazing.com/?page_id=3'>Show All</a></li></ul></li>		<li id="recent-posts" class="widget widget_recent_entries">			<h2 class="widgettitle">Recent Posts</h2>			<ul>
						<li><a href="http://sleepamazing.com/?p=68">Sleep Amazing Site Coming Together </a></li>
						</ul>
		</li>			<li><!-- BEGIN LivePerson Button Code -->
 
            <div id="chatcontainer">
            	<table border='0' cellspacing='2' cellpadding='2'>
                	<tr>
                    	<td align='center'><a id="_lpChatBtn" href='https://server.iad.liveperson.net/hc/6461214/?cmd=file&file=visitorWantsToChat&site=6461214&byhref=1&SESSIONVAR!skill=Customer%20Service&imageUrl=https://images.liveperson.com/lp/6461214' target='chat6461214'  onclick="lpButtonCTTUrl = 'https://server.iad.liveperson.net/hc/6461214/?cmd=file&file=visitorWantsToChat&site=6461214&SESSIONVAR!skill=Customer%20Service&imageUrl=https://images.liveperson.com/lp/6461214&referrer='+escape(document.location); lpButtonCTTUrl = (typeof(lpAppendVisitorCookies) != 'undefined' ? lpAppendVisitorCookies(lpButtonCTTUrl) : lpButtonCTTUrl); lpButtonCTTUrl = ((typeof(lpMTag)!='undefined' && typeof(lpMTag.addFirstPartyCookies)!='undefined')?lpMTag.addFirstPartyCookies(lpButtonCTTUrl):lpButtonCTTUrl);window.open(lpButtonCTTUrl,'chat6461214','width=475,height=400,resizable=yes');return false;" ><img src='https://server.iad.liveperson.net/hc/6461214/?cmd=repstate&site=6461214&channel=web&&ver=1&imageUrl=https://images.liveperson.com/lp/6461214&skill=Customer%20Service' name='hcIcon' border='0' alt='Customer Service' /></a>
                        </td>
                     </tr>
                     <tr>
                     	<td align='center'><div style="margin-top:5px;"><span style="font-size:10px; font-family:Arial, Helvetica, sans-serif;"><a href="http://solutions.liveperson.com/live-chat" style="text-decoration:none; color:#000" target="_blank"><b>Live Chat</b></a><span style="color:#000"> by </span><a href="http://www.liveperson.com/" style="text-decoration:none; color:#FF9900" target="_blank">LivePerson</a></span></div></td>
 
                     </tr>
                     <tr>
                     	<td align='center'><a href='http://solutions.liveperson.com/customer-service/?site=6461214&domain=server.iad.liveperson.net&origin=chatbutton' target='_blank'  onclick="javascript:window.open('http://solutions.liveperson.com/customer-service/?site=6461214&domain=server.iad.liveperson.net&origin=chatbutton&referrer='+escape(document.location));return false;" ><img src='https://server.iad.liveperson.net/hc/6461214/?cmd=rating&site=6461214&type=indicator' name='hcRating' alt='Customer Service Rating by LivePerson' border='0' /></a></td>
                      </tr>
					  <tr>
                        <td align="center"><p class="livechat">Agents are available to assist you <br />Mon - Fri 8 am - 4 pm PST.</p>
<p class="livechat">Click image to chat.</p></td>
					  </tr> 
                    </table> 
                </div>
 
            <!-- END LivePerson Button code -->		
            </li>
        	<li><div id='sideshoppingcart'><div id='shoppingcartcontents'>    <div id='sliding_cart' class='shopping-cart-wrapper'>
	
	
	<p class="empty">Your shopping cart is empty</p>
	<p class="visitshop">
	  <a href="http://sleepamazing.com/?page_id=3">Visit the shop</a>
	</p>
 
    </div></div></div></li>
        </ul>
	</div>
    <br />
 
</div>
 
<script src='http://intensedebate.com/js/wordpressTemplateLinkWrapper2.php?acct=e53111aab6285920e30a0c51e9b9f8d0' type='text/javascript'></script><div id="footer"><hr /><div id="ftrcol1"><!-- <br /> --><h3>About Us</h3><a href="http://sleepamazing.com/?page_id=2">Sleep Amazing</a><br /><a href="http://omniunlimited.com/">Omni Unlimited</a><br /><a href="http://sleepamazing.com/?page_id=372">Site Map</a><br /><a href="http://sleepamazing.com/?page_id=374">Links</a><br /><br /><br /><a href="http://wordpress.org/" class="logo"><img src="https://sleepamazing.com/wp-content/themes/commercial/images/WP_logo.jpg" alt="Powered by WordPress" class="logo" />Powered by Wordpress</a><br /><a href="http://www.instinct.co.nz/" class="logo"><img src="https://sleepamazing.com/wp-content/themes/commercial/images/instinct_logo.gif" alt="WP e-Commerce" class="logo" />WP e-Commerce</a><br /><br /></div><div id="ftrcol2"><!-- <br /> --><h3>Customer Service</h3><a href="http://sleepamazing.com/?page_id=26">Contact Us</a><br /><a href="https://sleepamazing.com/?page_id=681&order_history=true">Order Status</a><br /><a href="https://sleepamazing.com/?page_id=681">Account</a><br /><a href="http://sleepamazing.com/?page_id=82">About Your Order</a><br /></div><div id="ftrcol3"><!-- <br /> --><h3>Shipping & Returns</h3><form name="shipping_rates" action="https://sleepamazing.com/?page_id=402" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=402&quot;, &quot;shipping_rates&quot;, 500, 600)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;shipping_rates&quot;);">Shipping Rates</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><form name="delivery_times" action="https://sleepamazing.com/?page_id=404" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=404&quot;, &quot;delivery_times&quot;, 600, 800)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;delivery_times&quot;);">Delivery Times</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><form name="return_guarantee" action="https://sleepamazing.com/?page_id=406" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=406&quot;, &quot;return_guarantee&quot;, 600, 800)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;return_guarantee&quot;);">No Hassle Return Guarantee</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><br /><br /><a href="javascript://" onclick="javascript:window.open(&quot;https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside&quot;,&quot;olcwhatispaypal&quot;,&quot;toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350&quot;);"><img  src="https://sleepamazing.com/wp-content/themes/commercial/images/horizontal_solution_PPeCheck.gif" border="0" alt="Solution Graphics" /></a></div><div id="ftrcol4"><!-- <br /> --><h3>Security & Privacy</h3><form name="privacy_policy" action="https://sleepamazing.com/?page_id=426" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=426&quot;, &quot;privacy_policy&quot;, 500, 600)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;privacy_policy&quot;);">Privacy Policy</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><form name="terms_conditions" action="https://sleepamazing.com/?page_id=428" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=428&quot;, &quot;terms_conditions&quot;, 500, 600)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;terms_conditions&quot;);">Terms and Conditions</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><form name="satisfaction_guarantee" action="https://sleepamazing.com/?page_id=430" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=430&quot;, &quot;satisfaction_guarantee&quot;, 500, 600)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;satisfaction_guarantee&quot;);">Satisfaction Guarantee</a><input type="submit" name="fakeSubmitButton" style="display: none" /></form><br /><br /><br /><div id="secure_shoplogo"><form name="secure_shopping" action="https://sleepamazing.com/?page_id=389" method="post" onsubmit="return get_popup(&quot;https://sleepamazing.com/?page_id=389&quot;, &quot;secure_shopping&quot;, 500, 600)"><input type="hidden" name ="popup" value="true" /><a href="javascript:submit_form(&quot;secure_shopping&quot;);"><img src='https://sleepamazing.com/wp-content/themes/commercial/images/secure.gif' alt='Secure Shopping' class='securelogo' /><span class='securetext'>Secure Shopping Guarantee</span></a><input type="submit" name="fakeSubmitButton" style="display: none" /></form></div></div><div id="ftrcol5"><!-- <br /> --><h3>Professionals</h3><a href="https://sleepamazing.com/chiropractic/">Chiropractic Login</a><br /><a href="https://sleepamazing.com/sleepresearch/">Sleep Center Login</a><br /><a href="https://sleepamazing.com/othealthprofessionals/">Other Health Professionals</a><br /><br /><h3>Associates</h3><a href="https://sleepamazing.com/associates/">Associates Login</a><br /><br /></div><p class="clearfloat"></p><div id="footerpromo"><div id="ftrpromocol1"><!-- <br /> -->	<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
 
	<script type="text/javascript">
		try {
			var pageTracker = _gat._getTracker("UA-9671413-1");
			pageTracker._trackPageview();
		} catch(err) {}
    </script>
    </div>
	<div id="ftrpromocol2">
                <!-- <br /> -->
		        &nbsp;
    </div>
	<div id="ftrpromocol3">
                <!-- <br /> -->
 
		        &nbsp;
    </div>
	<div id="ftrpromocol4">
                <!-- <br /> -->
		    </div>    
	<div id="ftrpromocol5">
                <!-- <br /> -->
		    </div>    
    </div>    
	</div>
 
	<p class="clearfloat"></p>
<div id="copyright">Sleep Amazing is an Omni Unlimited Company.  Copyright &copy; 2009 by Omni Unlimited.  All rights reserved.<br />Please report problems with this website to <a href="mailto:webmaster@sleepamazing.com?subject=Problems with Sleep Amazing Website" style="font-size: 100%">webmaster@sleepamazing.com</a></div>
	<p class="clearfloat"></p>
<div id="ftrbtm1">
    <br />
                <br />
		</div>
 
<div id="ftrbtm2">
    	<br />
                <br />
		</div>
<br class="clearfloat" />
		</div><br />
<!-- BEGIN LivePerson Monitor. -->
	<script type="text/javascript">
 		var lpMTagConfig = {'lpServer' : "server.iad.liveperson.net",'lpNumber' : "6461214",'lpProtocol' : "http"};
		function lpAddMonitorTag(src){if(typeof(src)=='undefined'||typeof(src)=='object'){src=lpMTagConfig.lpMTagSrc?lpMTagConfig.lpMTagSrc:'/hcp/html/mTag.js';}
		if(src.indexOf('http')!=0){src=lpMTagConfig.lpProtocol+"://"+lpMTagConfig.lpServer+src+'?site='+lpMTagConfig.lpNumber;
		}else{
			if(src.indexOf('site=')<0){if(src.indexOf('?')<0)src=src+'?';else src=src+'&';src=src+'site='+lpMTagConfig.lpNumber;}};var s=document.createElement('script');s.setAttribute('type','text/javascript');s.setAttribute('charset','iso-8859-1');s.setAttribute('src',src);document.getElementsByTagName('head').item(0).appendChild(s);} if (window.attachEvent) window.attachEvent('onload',lpAddMonitorTag); else window.addEventListener("load",lpAddMonitorTag,false);</script>
<!-- END LivePerson Monitor. -->
<!-- BEGIN Monitor Tracking Variables  -->
	<script type="text/javascript">
		if (typeof(lpMTagConfig.sessionVar) == "undefined"){ lpMTagConfig.sessionVar = new Array();}
		lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = 'skill=Customer Service';
	</script>
 
<!-- End Monitor Tracking Variables  -->
</body>
</html>

Open in new window

profya:

CONGRATULATIONS!  You hit it on the head!!!  Yours was the only solution that worked.  Thank you.  Thank you so much.  Although your ranking is Master, you are a Genius in my book!

hielo:

Many, many thanks for your great effort in trying to find a solution to my problem.  Unfortunately, I tried everything you suggested and none gave me the results I wanted.
Thanks to all who participated.  I really, really appreciate all the help.
Just a post-note for anyone looking for a similar solution.  Thanks to profya's solution, I was able to come up with the following code to create a pseudo-multidimensional array in javascript that will reflect the contents of the $form_data array which contained the entire contents of the table query.  Hope it will be useful to someone.
// php file
?>
<script type="text/javascript">
     var form_field = [];
<?php foreach($form_data as $singleRow=>$singleField) {
           echo "index = '{$singleRow}';"; ?>	
           form_field[index] = [];
     <?php foreach($singleField as $index=>$value) {
	       echo "form_field[index]['{$index}'] = '{$value}';"; 
	  } 
      } ?>
      // rest of javascript code goes here
</script>
<?php

Open in new window