Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Setting/Selecting value from drop-down in PHP - Please help!

$
0
0

Hello ppl,

 

I am a newbie to PHP and I am stuck at a point which may be simple for you experts. Thus, please give your advice on the following:

 

Current Situation: The existing code of a web-page contains a dropdown with just one value in it. So when a user "presses" a submit button on this page, the ID of this single value in drop-down is saved in a variable and goes to another page.

 

What I want to do: I want to add more value in this dropdown (from a DB query which I have). And after using this query I see the required 4 values in dropdown now. But what I need now is that:

 

a. When I select any one value from the available 4 values, the respective ID should set in the variable which goes to another page. This is not happening.

 

b. The default value in the drop down should be one which I want. And thus, if I don't change the default selected value, then this value's ID should be stored in the variable which goes to next page.

 

Current Code (where some modification is to be done):

 

---------------------xxxxxxxxxxxxxxxx------------------xxxxxxxxxxxxxxxxxx----------------------xxxxxxxxxxxxxxx------------------xxxxxxx---------------

 

 

Case 24:
 
$output[] = '<tr><td>Order Name</td><td>Shipping Status</td> <td>Billing Y/N</td><td>Billing Date</td><td>Delivered Date</td><td>Order ID * hidden</td><td>Note</td></tr>';
while($row = oci_fetch_array($s,OCI_BOTH))
{
 
$output[] = '<tr><td><input type="text" name="txtOrderNm['.$j.']" class="widthed" value="'.$row["ORDER_NM"].'" readonly/></td>';
 
$output[] = '<td><select class="widthed" name="txtShippingStatusIDsup['.$j.']" style="width:138px;">';
if($row["REQUIRED_DT"]!=''){
$query1 = "select SHIPPING_STATUS_ID, SHIPPING_STATUS_NAME FROM SHIPPING_STATUS where SHIPPING_STATUS_ID =25";
}
else{
$query1 = "select SHIPPING_STATUS_ID, SHIPPING_STATUS_NAME FROM SHIPPING_STATUS where SHIPPING_STATUS_ID =24";
}
 
// currently only one value is coming in "SHIPPING_STATUS_ID" from the above query.
 
$s1 = oci_parse($conn, $query1);
oci_execute ($s1,OCI_DEFAULT);
while($row1 = oci_fetch_array($s1,OCI_BOTH))
{
 
$output[] = '<option value = "';
$output[] = $row1['SHIPPING_STATUS_ID'];
$output[] = '" ';
 
$output[] = '>';
$output[] = $row1['SHIPPING_STATUS_NAME'];
$output[] ='</option>';
}
$output[] = '</select></td>';
 
 
$output[] = '<td><input type="text" name="txtBillingYn['.$j.']" class="widthed" value="'.$row["BILLING_STATUS_YN"].'" readonly style="width:85px;"/></td>';
 
 
 
$output[] = '<td><input type="text" name="txtBillingDt['.$j.']" class="widthed" value="'.$row["BILLING_DT"].'" readonly style="width:100px;"/>';
$output[] = '</td>';
 
 
 
 
if($row["REQUIRED_DT"]!=''){
$output[] = '<td><input type="text" name="txtDeliveredDt['.$j.']" class="widthed" value="'.$row["REQUIRED_DT"].'" style="width:194px;" />';
$output[] = '<a href="#" onClick="setYears(1947, 2030); showCalender(this, \'txtDeliveredDt['.$j.']\');"><img src="./images/calender.png"></a>';
$output[] = '</td>';
$output[] = '<input type="hidden"  name="txtShippingStatusID['.$j.']"  value="24">';
}
else{
$output[] = '<td><input type="text" name="txtDeliveredDt['.$j.']" class="widthed" value="'.$today.'" style="width:194px;" />';
$output[] = '<a href="#" onClick="setYears(1947, 2030); showCalender(this, \'txtDeliveredDt['.$j.']\');"><img src="./images/calender.png"></a>';
$output[] = '</td>';
$output[] = '<input type="hidden"  name="txtShippingStatusID['.$j.']"  value="25">';
}
 
//comment
 
//below
 
// this value "txtShippingStatusID['.$j.']" is sent to another page. Since in this case, there is only one possible value for it, thus its hardcoded to '25'. But after I made my change, the value which gets stored in "txtShippingStatusID['.$j.']" should be of that row's ID which is selected in the dropdown. The modified query (original is above) is below:
 
// select SHIPPING_STATUS_ID, SHIPPING_STATUS_NAME FROM SHIPPING_STATUS where SHIPPING_STATUS_ID in (23,24,25,26);
 
//thus, the above code is to be changed such that "txtShippingStatusID['.$j.']" should store in it the value selected in drop-down.
 
//comment
 
//above
 
 
$output[] = '<td><input type="text" name="txtOrderID['.$j.']
" class="widthed" value="'.$row["ORDER_ID"].'" readonly style="width:150px;"/>';
$output[] = '</td>';
$output[] = '<td><input type="text" name="txtnote['.$j.']
" class="widthed" value="'.$row["note"].'" />';
$output[] = '</td>';
echo "<hr>";
}
break;
 
---------------------xxxxxxxxxxxxxxxx------------------xxxxxxxxxxxxxxxxxx----------------------xxxxxxxxxxxxxxx------------------xxxxxxx---------------

 

 

 

Any help appreciated....

 

Thanks!

 

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles