Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit values to a parent page

Status
Not open for further replies.

new2everything

IS-IT--Management
Sep 17, 2009
6
GB
I have a code to submit values from child page to the parent page but some of the inputs I take values from are conditional or repeat - defined by php and the values are not transferred. Please help, this is my code (the relevant bits):

Code:
<head>

<script langauge="javascript"> 
function post_value(){ 
    opener.document.new_item.new_supplier_id.value = document.product.supplier_id.value;
    var contactElement = document.getElementById("suplier2_id");
    if (contactElement != null)
      {	
      opener.document.new_item.new_supplier2_id.value = document.product.supplier2_id.value;
      }
    var contactElement = document.getElementById("suplier_contact");
    if (contactElement != null)
      {	
      opener.document.new_item.new_supplier_contact.value = document.product.supplier_contact.value;
      }
    var contactElement = document.getElementById("suplier2_contact");
    if (contactElement != null)
      {	
      opener.document.new_item.new_supplier2_contact.value = document.product.supplier2_contact.value;
      }
    opener.document.new_item.new_product_code.value = document.product.code.value; 
    opener.document.new_item.new_product_name.value = document.product.name.value; 
    self.close(); 
} 
</script>

</head

<body>

  <form id="product" name="product" method="post" action="" style="margin-top:0; margin-bottom:0">

    <input name="supplier_id" type="radio" value="<?php echo $supplier_id; ?>" />
    <?php if ($supplier2_id) { ?><input name="supplier2_id" id="supplier2_id" type="text" value="<?php echo supplier2_id; ?>" /><?php } ?>
      
    <?php 
    if ($row_rsContacts['ContactID']) { 
      do { ?>
        <input name="supplier_contact" id="supplier_contact" type="radio" value="<?php echo ucwords($row_rsContacts['SupplierContactName']); ?>" />
      <?php 
      } while ($row_rsContacts = mysql_fetch_assoc($rsContacts));
    }
    ?>

    <?php 
    if ($supplier2_id) {
      if ($row_rsContacts2['ContactID']) { 
        do { ?>
          <input name="supplier2_contact" id="supplier2_contact" type="radio" value="<?php echo ucwords($row_rsContacts2['SupplierContactName']); ?>" />
        <?php 
        } while ($row_rsContacts2 = mysql_fetch_assoc($rsContacts2));
      }
    }
    ?>

    <input name="code" type="hidden" value="<?php echo $row_rsProducts['ProductID']; ?>" />
    <input name="name" type="hidden" value="<?php echo $row_rsProducts['ProductName']; ?>" />
    <input type="button" value="Add Product" onclick="post_value();" />

  </form>

</body>

Only the following are transferred: code and name.

I will really appreciate your help.
 
Maybe you should post in a PHP forum or copy there the HTML result ...

Cheers,
Dian
 
Instead of posting the PHP code do a view source and post the resulting HTML after the PHP has been processed so we know what it looks like.

Then maybe we can offer some more help.

But for starters you are creating several elements which all have the same name and Id so there's no way to tell them apart.

Perhaps trying to get an array of elements with the same name and then using that to pass the values back may be better.

Also you are assigning the values back to a single thing, so what happens to the rest since there are supposedly more values that need to be passed?

Are they supposed to be concatenated into the single value or do you have more than one receiving element for them in your parent page?


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top