scottybwoy Posted January 11, 2007 Share Posted January 11, 2007 Hi All,I have a problem with my Select, field in my template. It uses php to recieve the options, which works fine. Selecting the options is ok except for the first one! Even if I select another and then select the original. Here's the code :[code]<?php<label for='type'>Customer Type :</label> <select action='submit' name='type' tabindex='12'> <?php while ($tRow = mssql_fetch_array($sqlT)) { // Loop through each element if ($tRow[0] == $data_array["type"]) { echo "<option value='" . $tRow[0] . "' selected='selected'>" . $tRow[1] . "</option>"; } else { print("<option value='" . $tRow[0] . "'>" . $tRow[1] . "</option>"); } } ?> </select> <div id="inf_type" class='sp'> </div> <label for='pay'>Payment Method :</label> <select action='submit' name='pay' tabindex='13'> <?php while ($pRow = mssql_fetch_array($sqlP)) { // Loop through each element if ($pRow[0] == $data_array["pay"]) { echo "<option value='" . $pRow[0] . "' selected='selected'>" . $pRow[1] . "</option>"; } else { print("<option value='" . $pRow[0] . "'>" . $pRow[1] . "</option>"); } } ?> </select>?>[/code]Array offset [0] is figures, 0, 1, 2 etc. Whilst offset [1] is the text. When int '0' is sent via POST is it classed as NULL? Thanks Link to comment https://forums.phpfreaks.com/topic/33748-strange-select-problem/ Share on other sites More sharing options...
chronister Posted January 11, 2007 Share Posted January 11, 2007 Maybe I am missing something or not familiar with this technique, but shouldn't this[code]<select action='submit' name='type' tabindex='12'>[/code]be [code]<form action="processingpage.php" name="form"><select name='type' tabindex='12'>[/code]Nate Link to comment https://forums.phpfreaks.com/topic/33748-strange-select-problem/#findComment-158279 Share on other sites More sharing options...
kenrbnsn Posted January 11, 2007 Share Posted January 11, 2007 I don't think the OP posted the entire script, so the <form> tag is not in the segment that was posted.Ken Link to comment https://forums.phpfreaks.com/topic/33748-strange-select-problem/#findComment-158282 Share on other sites More sharing options...
scottybwoy Posted January 11, 2007 Author Share Posted January 11, 2007 Lol yes the <form> is further up. But was would like to know how 0 is delt with in a $_POST array? Cos it seems to only happen for those values. Is their a workaround for this. Link to comment https://forums.phpfreaks.com/topic/33748-strange-select-problem/#findComment-158285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.