Jump to content

drop down help


cbrooks

Recommended Posts

I have a input screen where one of the inputs is selected via the following dropdown

 

<code>

$query="select customer_nbr, cust_name from web05a";

$result=pg_query($sqlconnection, $query);

$rows=pg_num_rows($result);

echo "<tr><td align='right'>Associated Company:</td>";

echo "<td><select name='ucompany'>";

for ($i=0;$i<$rows;$i++){

    $row=pg_fetch_array($result);

    $cname=$row['customer_nbr']." : ".$row['cust_name'];

    echo "<option value='{$row['customer_nbr']}'>$cname</option>";

  }

echo "</select>";

</code>

 

This dropdown works great, my problem is that I need to have a second drop down immediately following this one whery my db query would depend on the value comming from the first dropdown.

 

my second query would be as follows:

$query="select ship_nbr, ship_name, ship_line from web06a where customer_nbr=VALUE FROM THE FIRST DROPDOWN

 

From the resulting table I would then fill in the second dropdown list

 

Help will be appreciated.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

OK, I see where the function is getting the info selected, but 'Just Call Me Slow' but I need you to explain how that gets me anywhere closer to filling in the second dropdown on the fly?

 

Some I need more of a slap in the head and then a very hard push, instead of a gentle bump!!!

Link to comment
Share on other sites

OK, I got that to work and here is where I am:

 

Just working within the code that you pointed me to:

 

changed their first drop down so that it loads from my database table as per the origninal code that I mentioned. It works ok.

 

Now, when I select a record from the drop down list and click on the 'Submit' button it does load the second drop down list as I require and I can select an item from it. So far so good!

 

Now, I guess my problem now is with the <form>

Once I have selected an item from each drop down, then that info needs to be passed to another program which updates another database table with the selected info.

 

This <form> sends to $_POST to its self, so how do I get the info to the next step?

Link to comment
Share on other sites

Now, when I select a record from the drop down list and click on the 'Submit' button it does load the second drop down list as I require and I can select an item from it. So far so good!

 

You shouldn't have to click submit,

 

This <form> sends to $_POST to its self, so how do I get the info to the next step?

You can change the form to post anywhere, as it doesn't affect the drop downs, as they are controlled via ajax

Link to comment
Share on other sites

OK, if I understand you correctly, then if I copy the code from the pointed to topic, copy it to my site, run it as is then it should work! I select something from the first drop down and something will then appear in the second drop down allowimg me to select something from it???

 

If that is what is supposed to happen, then it ain't happening on my end. I tried the version that required no database and then tried the one using a database with same results.

 

My understanding is that I select something from first drop down and it then uses that result to place items in the second drop down????

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.