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

  • Home
  • SEARCH
  • 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 8006665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:35:21+00:00 2026-06-04T17:35:21+00:00

i want to open a specific window according to a drop down selection, the

  • 0

i want to open a specific window according to a drop down selection, the function works fine on the first row of a set of data (pulling it from a database)
Since i don’t know how many rows are going to come each time the script is running, i’ve created a loop and writting the function as many times as rows there are coming, having them named different.
The thing is that when i change the drop down from the first row, the correct window opens, for instance custom.php?id=1, but when i open the second one, if i select comunicarse from the list, it opens custom.php?id=2 (id=2 is the user’s id)
Here is the code, and i really hope you can understand me….

 <html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
<style>
table {
border-style:ridge;
border-width:1px solid;
border-collapse:collapse;
font-family:sans-serif;
font-size:12px;
width:100%;
}
table thead th, table.excel tbody th {
background:#CCCCCC;
border-style:ridge;
border-width:1;
text-align: center;
vertical-align:bottom;
}
table tbody th {
text-align:center;

}
table tbody td {
vertical-align:bottom;
}
table tbody td {
padding: 0 3px;
border: 1px solid 0000000;
}

table  td {
padding: 0 3px;
border: 1px solid 0000000;

}

</style>


<link rel="stylesheet" href="../css/style.css" type="text/css">



<?php 
include("../../cons/dbinfo.php");

$busco_react = "SELECT * 
FROM  `envios_mercadolibre` 
WHERE status != 'ENTREGADA'  AND status != 'CANCELADA' AND aviso != 1";
$bus1 = mysql_query($busco_react);
while ($b1 = mysql_fetch_array($bus1)){
$para = $b1['id'];

echo '<script language="Javascript" type="text/javascript">
function ReactToChange'.$para.'()
{
if (document.getElementById("DropDownList").value === "custom")
{
    window.open("custom.php?id='.$para.'")
}
else if (document.getElementById("DropDownList").value === "comunicarse")
{
    window.open("comunicarse.php?id='.$para.'")
}
else if (document.getElementById("DropDownList").value === "esperando")
{
    window.open("esperando.php?id='.$para.'")
}
else if (document.getElementById("DropDownList").value === "compro")
{
    window.open("compro.php?id='.$para.'")
}
else {}
}
</script>';

 }
?>
</head>
<body>
<table width = "2200px">
<tr><td colspan="3" align="center"><a href="../index.php">Back to index</a></td></tr>
</table>
<br />
<?php 

echo "<form method='post' action='sendemails.php'>";
echo "<table  border='1' cellpading ='0' cellspacing ='0'>";
echo "<thead><tr><th>MAIL</th><th>Email Address</th><th>Content</th>
<th>Extra 1</th><th>Extra 2</th><th>Full Address</th><th>Full Name</th></tr>
</thead><tbody>";

$bus = "SELECT * FROM  `envios_mercadolibre` WHERE status != 'ENTREGADA'  AND status   !=    'CANCELADA' AND aviso != 1";
$bu = mysql_query($bus) or die("este");
while ($b = mysql_fetch_array($bu)){
$contenido = $b['contenido'];
$extra1 = $b['extra1'];
$extra2 = $b['extra2'];
$usuario_id = $b['usuario_id'];
$para1 = $b['id'];

$datosUsuario = "SELECT nombre, apellido, email from usuarios WHERE id = $usuario_id";
$datosU = mysql_query($datosUsuario) or die("foo");
while ($c = mysql_fetch_array($datosU)){
$nombre = $c['nombre'];
$apellido = $c['apellido'];
$email = $c['email'];


$todoelnombre = $nombre.", ".$apellido;

echo "<tr>
<td><select id='DropDownList' onchange='ReactToChange$para1()'>
<option value='later'>LATER</option>
<option value='comunicarse'>COMUNICARSE CON NOSOTROS</option>
<option value='esperando'>ESPERANDO CALIFICACION EN MERCADO LIBRE</option>
<option value='compro'>NO COMPRO</option>
<option value='custom'>CUSTOM</option>
</select></td>
<td>$email</td>
<td>$contenido</td>
<td>$extra1</td>
<td>$extra2</td>
<td>$todaladire</td>
<td>$todoelnombre
<input type='hidden' name ='datos-$para1' value ='$email' />
</td>
</tr>
";



}

}

echo "<tr><TD colspan ='7' align='center'><input type='submit' /></td></tr></table>";




?>


</div>
</body>
</html>
  • 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-04T17:35:22+00:00Added an answer on June 4, 2026 at 5:35 pm

    It’s hard to tell an exact answer without seeing your database structure, but at first I would not create your javascript function inside the while loop, as it will make several functions. On the top of that you really do not need the first SELECT if you use a parameterized javascript function that you call later with the apropriate parameters.

    I have modified your code, please take a look at a more effective javascript function and its calling below:

    <html>
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title></title>
    <style>
    table {
    border-style:ridge;
    border-width:1px solid;
    border-collapse:collapse;
    font-family:sans-serif;
    font-size:12px;
    width:100%;
    }
    table thead th, table.excel tbody th {
    background:#CCCCCC;
    border-style:ridge;
    border-width:1;
    text-align: center;
    vertical-align:bottom;
    }
    table tbody th {
    text-align:center;
    
    }
    table tbody td {
    vertical-align:bottom;
    }
    table tbody td {
    padding: 0 3px;
    border: 1px solid 0000000;
    }
    
    table  td {
    padding: 0 3px;
    border: 1px solid 0000000;
    
    }
    
    </style>
    
    <link rel="stylesheet" href="../css/style.css" type="text/css">
    
    <script language="Javascript" type="text/javascript">
    function ReactToChange(para,ptype)
    {
        window.open(ptype+".php?id="+para);
    }
    </script>
    
    </head>
    <body>
    <table width = "2200px">
    <tr><td colspan="3" align="center"><a href="../index.php">Back to index</a></td></tr>
    </table>
    <br />
    <?php 
    
    echo "<form method='post' action='sendemails.php'>";
    echo "<table  border='1' cellpading ='0' cellspacing ='0'>";
    echo "<thead><tr><th>MAIL</th><th>Email Address</th><th>Content</th>
    <th>Extra 1</th><th>Extra 2</th><th>Full Address</th><th>Full Name</th></tr>
    </thead><tbody>";
    
    $bus = "SELECT * FROM  `envios_mercadolibre` WHERE status != 'ENTREGADA'  AND status   !=    'CANCELADA' AND aviso != 1";
    $bu = mysql_query($bus) or die("este");
    while ($b = mysql_fetch_array($bu)){
    $contenido = $b['contenido'];
    $extra1 = $b['extra1'];
    $extra2 = $b['extra2'];
    $usuario_id = $b['usuario_id'];
    $para1 = $b['id'];
    
    $datosUsuario = "SELECT nombre, apellido, email from usuarios WHERE id = $usuario_id";
    $datosU = mysql_query($datosUsuario) or die("foo");
    while ($c = mysql_fetch_array($datosU)){
    $nombre = $c['nombre'];
    $apellido = $c['apellido'];
    $email = $c['email'];
    
    
    $todoelnombre = $nombre.", ".$apellido;
    
    echo "<tr>
    <td><select id='DropDownList' onchange='ReactToChange($para1,this.options[this.selectedIndex].value)'>
    <option value='later'>LATER</option>
    <option value='comunicarse'>COMUNICARSE CON NOSOTROS</option>
    <option value='esperando'>ESPERANDO CALIFICACION EN MERCADO LIBRE</option>
    <option value='compro'>NO COMPRO</option>
    <option value='custom'>CUSTOM</option>
    </select></td>
    <td>$email</td>
    <td>$contenido</td>
    <td>$extra1</td>
    <td>$extra2</td>
    <td>$todaladire</td>
    <td>$todoelnombre
    <input type='hidden' name ='datos-$para1' value ='$email' />
    </td>
    </tr>
    ";
    
    
    
    }
    
    }
    
    echo "<tr><TD colspan ='7' align='center'><input type='submit' /></td></tr></table>";
    
    
    
    
    ?>
    
    
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open a new browser window with a specific url (say http://google.com
I want to set up an image button (OPEN) with an onclick() function that
I want to open a specific subpage of my CHM -Help for my program.
I want to open a specific URL(relatively easy to achieve in Watir/WatiN), then click
I want to open a new browser window without menu bar, tool bar or
i want to know how i can open a browser to a specific web
How can I open a cmd window in a specific location without having to
I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly
I want to open a file from a Class in C# using a Process,
I want to open a file for reading. However, in the context of this

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.