Page 2 of 2
Posted: Thu Sep 28, 2006 6:08 am
by volka
f=document.getElementByID("form");
[...]
<form method='POST' name='form' action='#'>
The element has a name but not an id.
function send()
[...]
onchange="trimitere()"
document.getElementById("camp").value=.options[mylist.selectedIndex].text;
try
Code: Select all
<html>
<head>
<title>...</title>
<script language="javascript">
function trimitere()
{
mylist=document.getElementById("test1");
mytext = document.getElementById("camp1")
if ( null==mylist || null==mytext ) {
alert("An error has occured, where sorry for the incovience!");
return;
}
mytext.value = mylist.value; // options[mylist.selectedIndex].value;
}
</script>
</head>
<body>
<form method="POST" action="#">
<select id="test1" onchange="trimitere()">
<option value="Test 1" >Test 3</option>
<option value="Test 2">Test 4</option>
</select>
<br />
Result: <input type="text" id="camp1" value="" />
</form>
</body>
</html>
Posted: Thu Sep 28, 2006 6:44 am
by Rovas
Sorry about these, I was in a hurry to put the code, and I got distracted :
function send()
[...]
onchange="trimitere()"
Quote:
document.getElementById("camp").value=.options[mylist.selectedIndex].text;
Thanks man for all the help.
Now it works in the test page let' s see in the actual page how it works.
Posted: Thu Sep 28, 2006 9:02 am
by Rovas
It partially works for selected values and loading and displaying the others dropdown menus. There still some bugs to fix:
what if the user what' s to change in mid selection the category, problems with displaying the data selected in the menu.
And I still hadn' t made the part for retrieving data from cookies if the user comes from a product page and wants to compare it with another.
Posted: Fri Sep 29, 2006 5:27 am
by Rovas
I don' t know how to display the selected value after it' s been selected and the form has been submitted i.e. user selects name of the category from the dropdown menu, the form is submited through JavaScript because of the onchange event in the dropdown menu and the user see the selected value in the menu and the new menus that appeared because of his selection.
EDIT: I don' t have any good ideas for doing this: I tried echoing the selected value with PHP, using the selected property with JS but after the reloading the page it switch to the first value in the menu.
Any ideas, snippets of code (JS or PHP) will be very much appreciated
Posted: Fri Sep 29, 2006 6:05 am
by volka
If you mark an option as
<option selected="selected"> browsers show this option as current value of a select element.
As for the whole topic:
viewtopic.php?t=55508#309978
bokehman wrote:Just in case you want to Google it, the proper terminology is a "
chained select".
Posted: Fri Sep 29, 2006 7:11 am
by Rovas
Thank you once again for the help. Need time to process the information given and then to finally finish this page.