seems i was a little unpreciss with my explication
name,hoby,age is only for example, i want to use any records from database, so if you are so kind to explain all the process
thx
Main Topics
Browse All TopicsHello!
I have a database with a table like this
ID Name Hobby Age
1 John sport 23
2. Mary music 21
3. Dave movies 25
4. Jabe reading 22
And in my php page i have 2 selects and one text box
I put in select1 and select2 values Name and Hobby, text box is read only
What i want is
When i select something from select 1 automatically in select 2 will be select coresponding value and in text box same thing (age)
Of course when i select something in select 2 same thing to be happend in select 1 and text box
example.
if i select mary (select 1) in select 2 will appear music and in text box 21
if i select movies (select 2) in select 1 will appear Dave and in text box 25
Thanks
p.s. All values i use is distinct (will not be 2 persons with same name or hobby)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Si_HibbardPosted on 2006-03-02 at 04:08:56ID: 16083911
Heres a basic example which you can modify. it could be improved for ease of re-use if you wanted by looping through all the objects on the page and identifying and id staring with "sel" and setting its selectedIndex value. Otherwise just add the elements as the example shows eg
el*");
his);" id="sel*">
el1"); el2");
his);" id="sel1"> his);" id="sel2">
add where *
in the javascript:
sel = document.getElementById("s
sel.selectedIndex = objIn.selectedIndex;
In the html:
<select onChange="updateSelected(t
<option value="1">sport</option>
<option value="2">music</option>
<option value="3">movies</option>
</select>
----------------------
Example code:
----------------------
<script type="text/javascript">
function updateSelected(objIn)
{
var obj, sel;
//alert(objIn.value);
sel = document.getElementById("s
sel.selectedIndex = objIn.selectedIndex;
sel = document.getElementById("s
sel.selectedIndex = objIn.selectedIndex;
}
</script>
<select onChange="updateSelected(t
<option value="1">john</option>
<option value="2">mary</option>
<option value="3">dave</option>
</select>
<select onChange="updateSelected(t
<option value="1">sport</option>
<option value="2">music</option>
<option value="3">movies</option>
</select>