Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:40:22+00:00 2026-06-05T18:40:22+00:00

I have, with the help of the SO community written a javascript and php

  • 0

I have, with the help of the SO community written a javascript and php page that allows me to pass a value from the popup page back to the parent page.

This works 100% on internet explorer but not in google chrome or on my ipad / galaxt tablet.

Any idea on how this can be corrected? Any help appreciated as always.

Below is portions of my code from the parent page(newsale.php) and the popup page(sku.php). I know that other methods are recommended over using popup but I need to get this solution working with the popup page for application reasons.

newsale.php Parent Page (Code snippets, not entire page)

<script type="text/javascript">  
function selectValue(id) 
{ 
    // open popup window and pass field id 
    window.open('sku.php?id=' + encodeURIComponent(id),'popuppage', 
      'width=1000,toolbar=1,resizable=1,scrollbars=yes,height=200,top=100,left=100'); 
} 

function updateValue(id, value) 
{ 
    // this gets called from the popup window and updates the field with a new value 
    document.getElementById(id).value = value; 
} 

</script> 

<table>
<tr id="r1">  
<input size=10  type=number id=sku1 name=sku1 onchange="showUser(1, this.value)" <? if($rows>0){echo "value=".mysql_result($resultorder,0,1);}  ?>><img src=q.png  name="choice" onClick="selectValue('sku1')" value="?">
</td>
</tr>
<tr id="r2"> 
<td>
<input size=10  type=number id=sku2 name=sku2 onchange="showUser(2, this.value)" <? if($rows>1){echo "value=".mysql_result($resultorder,1,1);}  ?> ><img src=q.png  name="choice" onClick="selectValue('sku2')" value="?">
</td>
</tr>
</table>

sku.php Popup Page (entire page)

<? 

  $con = mysql_connect('localhost', 'username', 'password'); 
 if (!$con) 
   { 
   die('Could not connect to server: ' . mysql_error()); 
   } 
   $db=mysql_select_db("DBName", $con); 

    if (!$db) 
   { 
   die('Could not connect to DB: ' . mysql_error()); 
   } 


$sql="select packcode,category,description,grouping,packconfig,sellingunits,eottpoints from skudata order by category, packcode";
$result=mysql_query($sql);

 ?> 

<script type="text/javascript"> 

  function AjaxFunction(cat_id) { 
    var httpxml; 
    try { 
      // Firefox, Opera 8.0+, Safari 
      httpxml = new XMLHttpRequest(); 
    } catch (e) { 
      // Internet Explorer 
      try { 
        httpxml = new ActiveXObject("Msxml2.XMLHTTP"); 
      } catch (e) { 
        try { 
          httpxml = new ActiveXObject("Microsoft.XMLHTTP"); 
        } catch (e) { 
          alert("Your browser does not support AJAX!"); 
          return false; 
        } 
      } 
    } 
    function stateck() { 
      if (httpxml.readyState == 4) { 
        var myarray = eval(httpxml.responseText); 
        // Before adding new we must remove previously loaded elements 
        for (j = document.testform.subcat.options.length - 1; j >= 0; j--) { 
          document.testform.subcat.remove(j); 
        } 
        for (i = 0; i < myarray.length; i++) { 
          var optn = document.createElement("OPTION"); 
          optn.text = myarray[i]; 
          optn.value = myarray[i]; 
          document.testform.subcat.options.add(optn); 
        }  
      } 
    } 
    var url="dd.php"; 
    url = url+"?cat_id="+cat_id; 
    url = url+"&sid="+Math.random(); 
    httpxml.onreadystatechange = stateck; 
    httpxml.open("GET",url,true); 
    httpxml.send(null); 
  } 

</script> 


 <script type="text/javascript"> 
 function sendValue(value)
 {
 var e = document.getElementById("subcat"); 
 value = e.options[e.selectedIndex].value; 
 var parentId = <?php echo json_encode($_GET['id']); ?>; 
 window.opener.updateValue(parentId, value); 
 window.close(); 
 } 
 </script>


 <script type="text/javascript"> 
function updateinput(){ 
var e = document.getElementById("subcat"); 
var catSelected = e.options[e.selectedIndex].value; 


document.getElementById("copycat").value=catSelected; 
} 
</script> 


<form name="testform">
Category: &nbsp; <select name=cat id=cat onchange="AjaxFunction(this.value);" style="width=300"> <br>
<option value='' style="width=300">Select One</option> 
<br>
<? 

  require "config.php";// connection to database  
  $q=mysql_query("select * from categories"); 
  while($n=mysql_fetch_array($q)){ 
    echo "<option value=$n[cat_id]>$n[category]</option>"; 
  } 

?> 
</select> 
 <br><br>
 Pack Code:
<select name=subcat onchange="updateinput();" > 
 <br><br>
</select>
<br><br>
<input type=hidden name=copycat id=copycat > 
<td><input type=button value="Select" onClick="sendValue(document.getElementById(copycat))" /></td>
</form> 

dd.php (for dynamic drop down list)

<? 

  $cat_id=$_GET['cat_id']; 
  require "config.php"; 
  $q=mysql_query("select concat(packcode,', ',description) as details from skudata where cat_id='$cat_id'"); 
  echo mysql_error(); 
  $myarray=array(); 
  $str=""; 
  while($nt=mysql_fetch_array($q)){ 
    $str=$str . "\"$nt[details]\"".","; 
  } 
  $str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string 
  echo "new Array($str)"; 

?> 

I dont think dd.php has any influence on the functionality of the parent popup relationship but have included it so you can follow the code.

As mentioned this works 100% on Internet explorer but not in google chrome or my ipad.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:40:23+00:00Added an answer on June 5, 2026 at 6:40 pm

    When you use

    document.getElementById("subcat");
    

    then you should also have an element with such an id. Your

    <select name=subcat onchange="updateinput();" >
    

    won’t do with browsers like chrome, firefox, konqueror and probably lots of others. Use

    <select id="subcat" onchange="updateinput();" >
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like some help from the community, if possible. We have a project at
I have done everything said on the following page. https://help.ubuntu.com/community/Django but it gives me
Can I have some help in improving this linq. I'm basically returning speakers from
I have an HTML help system that I need to convert to SharePoint. The
I'm a noob with mysql and php, and need some help :) I have
I need the community's help on this. We have TFS 2010 and SharePoint services
Hello! I have a little problem I was hoping the community could help me
UPDATE After lots of toiling, trouble and help from the community the following link
With the help of the Stack Overflow community I've written a pretty basic-but fun
I have a slightly tricky one here I hope the community can help me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.