hi,
i am new to web development. i have to develop a site where one can convert money from nzd and to nzd given a list of different currency. i need the calculate button to calculate the currency and convert the given amount. need to know how to go on about it.
My codes so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Currency.Models;
namespace Currency.Controllers
{
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
financeInit();
return View();
}
public void financeInit()
{
financeEntities db = new financeEntities();
ViewData["exchrateList"] = db.exchrates.ToList();
ViewData["Convert From NZD"] = "";
ViewData["Convert To NZD"] = "";
ViewData["The other currency is:"] = "";
ViewData["You wish to convert"] = "";
ViewData["That will produce"] = "";
}
public ActionResult financeCurrencyConvert()
{
return View();
}
public ActionResult finance()
{
{
financeInit();
if (Request.Params["submitter"] == "Calculate")
financeCurrencyConvert();
return View();
}
}
}
}
<HTML>
<HEAD>
<TITLE>NZ Currency Converter</TITLE>
</HEAD>
<BODY>
<form name="Currency Converter" method="post" />
<tr>
<td>
<input type="radio" name="convert" value="Y" <%if (String.Compare((String) ViewData["convert"],"Y",false)==0) Response.Write("checked"); %> />Convert From NZD<br />
<input type="radio" name="convert" value="N" <%if (String.Compare((String) ViewData["convert"],"Y",false)==0) Response.Write("checked"); %> />Convert To NZD
</td>
</tr>
<p><tr>
<td colspan="2" align="right"> The other currency is:</td>
<td>
<select name="exchrate">
<% List<Currency.Models.exchrate> exchrateList = (List <Currency.Models.exchrate>) ViewData["exchrateList"];
foreach (Currency.Models.exchrate st in exchrateList)
{
%>
<option value="<% Response.Write(st.othercurrency);%>">"<% Response.Write(st.fromnzd);%>">"<% Response.Write (st.tonzd);%>"> </option>
<% } %>
<option value=""></option>
</select>
</td>
</tr>
</p>
<p>
<tr><td colspan="2" align="right"> You wish to convert: <input type="text" name="calculate" size="30" />
<input type="submit" name="submitter" value="calculate"onclick="return buttclick_confirm('calculate')"; />
</td>
</tr>
</p>
<p>
<tr><td colspan="2" align="right"> That will produce:<input type="hidden" name="currency" </td></tr></p>
</form>
</BODY>
</HTML>