Help with Arrays
Page 1 of 1
Help with Arrays
Dear Forum,I am looking for a solution to the following problem for which I am not sure if HTML is the answer. Basically I want to do the following:
I have a dropdownlist with values from this array $Deutsch = Array(eins, zwei, drei, vier, fünf, sechs, sieben, acht, neun, zehn) then, when a value is selected from the first array $Deutsch, the value from the second array $Englisch = Array(one, two, three, four, five, six, seven, eight, nine, ten) is displayed in a box next to the dropdownlist
Is this something that can be achieved with html?
Thank you in advance for your assistance
Array
Re: Help with Arrays
yes you can achieve it by java script like this- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML.net Select List Filter</title>
<script type="text/javascript">
var English = Array(
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten'
);
function loadSelect() {
var Deutsch = {
eins : 'eins',
zwei : 'zwei',
drei : 'drei',
vier : 'vier',
fünf : 'fünf',
sechs : 'sechs',
sieben : 'sieben',
acht : 'acht',
neun : 'neun',
zehn : 'zehn'
};
//alert("Hello");
var select = document.getElementById("list1");
for(index in Deutsch) {
select.options[select.options.length] = new Option(Deutsch[index], index);
}
}
function filter() {
var select = document.getElementById("list1");
document.getElementById("result").text = ""
document.getElementById("result").value = English[select.selectedIndex];
//English[select.selectedIndex];
//alert(select.selectedIndex);
}
</script>
</head>
<body onload="loadSelect()">
<p>
<select id="list1">
</select>
<input type="button" onclick="filter()" value="Convert" />
</p>
<textarea name="result" id="result" cols="45" rows="5"></textarea>
<p> </p>
</body>
</html>
Re: Help with Arrays
I loaded this into a worpress page and all I got was a blank dropdown and a blank box or did I do something wrong?Thank you for your assistance
XainPro wrote:yes you can achieve it by java script like this
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML.net Select List Filter</title>
<script type="text/javascript">
var English = Array(
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten'
);
function loadSelect() {
var Deutsch = {
eins : 'eins',
zwei : 'zwei',
drei : 'drei',
vier : 'vier',
fünf : 'fünf',
sechs : 'sechs',
sieben : 'sieben',
acht : 'acht',
neun : 'neun',
zehn : 'zehn'
};
//alert("Hello");
var select = document.getElementById("list1");
for(index in Deutsch) {
select.options[select.options.length] = new Option(Deutsch[index], index);
}
}
function filter() {
var select = document.getElementById("list1");
document.getElementById("result").text = ""
document.getElementById("result").value = English[select.selectedIndex];
//English[select.selectedIndex];
//alert(select.selectedIndex);
}
</script>
</head>
<body onload="loadSelect()">
<p>
<select id="list1">
</select>
<input type="button" onclick="filter()" value="Convert" />
</p>
<textarea name="result" id="result" cols="45" rows="5"></textarea>
<p> </p>
</body>
</html>
Re: Help with Arrays
did you checked it separately ?as a separate page !
did it work ?
Re: Help with Arrays
I found the problem I had the script blocker on now it works thank you.Re: Help with Arrays
ohhh ...i thought i just tested it on my PC and yet its not working but its script blocker which was creating trouble.
AND your welcome.
Regards,
XainPro
Page 1 of 1