Eduardo Fuerte
asked on
How to make the combo assume previous selected option code ?
Hi Experts!
If a combo starts with a marked option how to make the selected option code (sb_cccx in the example) to assume the initial value correspondent to the option selected despite the fact the user access the combo or not?
Thanks in advance!
If a combo starts with a marked option how to make the selected option code (sb_cccx in the example) to assume the initial value correspondent to the option selected despite the fact the user access the combo or not?
<tr>
<td>
CC/ Cx:
<select name="sb_cccx">
<option value="<?php echo $d_cccx;?>" selected> <?php echo $d_cccx;?></option>
</option>
<?php
//----------Inicio Combo 1 (CCCX) -----------------------------------------------------------------
$sql = mysql_query("select sb_cccx, cx_info, substr(descricao,1,25) as descricao from cccx where ativa=1 order by descricao");
//----------Final Combo 1-------------------------------------------------------------------------
while ($row = mysql_fetch_array($sql)) {
$id = $row['sb_cccx'];
$data = $row['descricao'];
echo '<option value="' . $id . '">' . $data . '</option>';
}
?>
</select>
</td>
</tr>
Thanks in advance!
If I'm understanding your question correctly, it will do exactly what you want. If you can post a link to the HTML document that is generated by this PHP code, I'll be glad to investigate further.
Didn't we answer this question earlier? Have a re-read through your previous question.
If you need the combo to have a previously selected option SELECTed then the answer was previously posted (by the two people whose answer you didn't accept...)
If you need the combo to have a previously selected option SELECTed then the answer was previously posted (by the two people whose answer you didn't accept...)
@ChrisStanyon: Yes, I think the answer is already there in the other question -- in one form or another. The understanding might be as simple as running the script, looking at the generated HTML document and using var_dump($_REQUEST) in the action script.
ASKER
Hello
ChrisStanyon
The question is similar and could cause confusion but it's different if you pay attention is easy to note, by the way your last reply didn´t work in my tests.
Ray
Send you the html like I did days ago to receive the same tests at W3C validator proved to be unproductive. Would you like it again to the same purposes?
ChrisStanyon
The question is similar and could cause confusion but it's different if you pay attention is easy to note, by the way your last reply didn´t work in my tests.
Ray
Send you the html like I did days ago to receive the same tests at W3C validator proved to be unproductive. Would you like it again to the same purposes?
@EFuerte - sorry - I'm not entirely sure what you want. If you want to select an option then you simply add 'selected' to it:
<select name="sb_cccx">
<option value"something" selected>This is selected</option>
.....
</select>
If you want to select a previously selected option then you need code to check each option against the previously selected option.
I guess I do not understand the question. I do not see anything wrong with your code, but I do not have any test data to work with, so it's unlikely that you can trust my vision. Can you please show us the SSCCE that illustrates the issue?
ASKER
Ok, using pictures.
1. Say the user needs to edit a register to change something, choose and ask to edit:
2. So he changes one of the combos
3. And doesn´t touch the others combos
4. So he try to saves it to BD.
The combo the user has changed receive the correct code but the others received incorrect "literal" codes. What I need is a way to store the previous code sent to the edit form for all the controls (touched or not) to permit a correct update then.
Hope clarify.
1. Say the user needs to edit a register to change something, choose and ask to edit:
2. So he changes one of the combos
3. And doesn´t touch the others combos
4. So he try to saves it to BD.
The combo the user has changed receive the correct code but the others received incorrect "literal" codes. What I need is a way to store the previous code sent to the edit form for all the controls (touched or not) to permit a correct update then.
Hope clarify.
The SQL error probably occurs because the open paren before ,4,100,CONDOMNIO... has a leading blank but no value before the comma.
I don't really know how to answer your question. Getting data from an HTML form into a PHP script is accomplished with the patterns shown in this tutorial. Getting data from the PHP script into the MySQL data base is taught in this book. Maybe you can store this information in an active record, or perhaps you can store it in the PHP session array.
I don't really know how to answer your question. Getting data from an HTML form into a PHP script is accomplished with the patterns shown in this tutorial. Getting data from the PHP script into the MySQL data base is taught in this book. Maybe you can store this information in an active record, or perhaps you can store it in the PHP session array.
ASKER
The sql string is not the focus and irrelevant by now, it will be correctly treated after I had the correct values received, where you've read CONDOMINIO it would be a numerical code from the combo, instead, not the literal from the combo.
But after more thinking it's a matter of check if the value received for the update is literal or numerical and in case of not being numeric, simple don't use it in update, since it's a symptom of not changed value...
But after more thinking it's a matter of check if the value received for the update is literal or numerical and in case of not being numeric, simple don't use it in update, since it's a symptom of not changed value...
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Ray
(Maybe you're celebrating Independence Day 4th July, if so, congratulations!)
Unfortunatelly no.
I need a way to associate a numerical code corresponding to every combo based on an existing BD register when the form charges.
If someone decides to edit existing information and don't change some of the combos, the code informations of this combos must be what the form received at the start, otherwise it incorrectly sends litteral values.
I hope it clarifies.
(Maybe you're celebrating Independence Day 4th July, if so, congratulations!)
Unfortunatelly no.
I need a way to associate a numerical code corresponding to every combo based on an existing BD register when the form charges.
If someone decides to edit existing information and don't change some of the combos, the code informations of this combos must be what the form received at the start, otherwise it incorrectly sends litteral values.
I hope it clarifies.
Sorry, I just don't get it. If you can create examples that show the before and after conditions maybe we can help.
ASKER
Hello
I've just treated the combo's reply used to insertion in DB, if it's literal it's a matter of find the correspondent code in a query. If it's numeric it's just ok to insertion in the correspondente column.
I've just treated the combo's reply used to insertion in DB, if it's literal it's a matter of find the correspondent code in a query. If it's numeric it's just ok to insertion in the correspondente column.