Jump to content

[JavaScript] Help in Locating two DropDownList Box


jiyeonnie
 Share

Recommended Posts

[/left][left]<form>[/left][left]<fieldset id="field"><legend>Oversea Currency Rates</legend><dl><dt><label for="currency">Currency</label></dt><dd><select id="cur" name="cur"><option value="SGD">SGD</option><option value="USD">USD</option><option value="EUR">EUR</option><option value="GBP">GBP</option><option value="CNY">CNY</option><option value="JPY">JPY</option><option value="KRW">KRW</option></select><input type="text" size="16" required="required" id="curr" placeholder="Enter Amount" /></dd></dl><dl><dt><label for="to">Convert to</label></dt><dd><select id="next" name="next"><option value="SGD">SGD</option><option value="USD">USD</option><option value="EUR">EUR</option><option value="GBP">GBP</option><option value="CNY">CNY</option><option value="JPY">JPY</option><option value="KRW">KRW</option></select></dd></dl><br /><dl><dt></dt><dd><input type="button" onclick="convert()" value=" Convert " /><input type="reset" value="  Reset  "/></dd></dl><dl><dt><label for="cost">Converted Amount</label></dt><dd><input type="text" size="16" disabled="disabled" id="final"/></dd></dl></fieldset>

function convert() {		  var CurSel = cur.options[cur.selectedIndex].value;		  var amt = document.getElementById("curr").value;		  var final = document.getElementById("final").value;		  var next = next.options[next.selectedIndex].value;[/left]		  if (CurSel == "SGD") {			  switch (next) {			    case "SGD":				    final = amt * 0.05;				    break;			    case "USD":				    final = amt * 0.10;				    break;			    case "GBP":				    final = amt * 0.15;				    break;			    case "CNY":				    final = amt * 5.0;				    break;			    case "JPY":				    final = amt * 63.0;				    break;			    case "KRW":				    final = amt * 680.40;				    break;			  }		  }		  else if (CurSel == "USD") {                    ~Same as above~		  }		  else if (CurSel == "EUR") {                    ~Same as above~		  }		  else if (CurSel == "GBP") {                    ~Same as above~		  }		  else if (CurSel == "CNY") {                    ~Same as above~		  }		  else if (CurSel == "JPY") {                    ~Same as above~		  }		  else if (CurSel == "KRW") {		  }	  }

I have learnt how to locate one Dropdown list in JavaScript, however... i tried another file with 2 DDL and i cant seem to make it work... Tried "trouble-shooting" it myself and wasted lots of time ~~ So i'm getting professional help! Thanks in advance!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...