Login | Register | FAQ
Anonymous

Help with Arrays

+ Post a reply

Page 1 of 1


Help with Arrays

by Array » Sun Apr 29, 2012 10:40 am

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
User avatar

Array

  • Posts: 7
  • Joined: Sun Apr 29, 2012 10:16 am

Re: Help with Arrays

by XainPro » Mon Apr 30, 2012 7:57 am

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>&nbsp;</p>
</body>
</html>
User avatar

XainPro

  • Posts: 3311
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Help with Arrays

by Array » Fri May 04, 2012 6:48 am

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>&nbsp;</p>
</body>
</html>
User avatar

Array

  • Posts: 7
  • Joined: Sun Apr 29, 2012 10:16 am

Re: Help with Arrays

by XainPro » Sat May 05, 2012 5:16 am

did you checked it separately ?
as a separate page !
did it work ?
User avatar

XainPro

  • Posts: 3311
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Help with Arrays

by Array » Sun May 06, 2012 9:50 am

I found the problem I had the script blocker on now it works thank you.
User avatar

Array

  • Posts: 7
  • Joined: Sun Apr 29, 2012 10:16 am

Re: Help with Arrays

by XainPro » Mon May 07, 2012 4:14 am

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
User avatar

XainPro

  • Posts: 3311
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1