What I'm trying to accomplish is a user would type in a item number and quantity into two textboxes. Then they click add and it would add it to a list on the screen, this would sort of be like a shopping cart. How would I go about doing that?
It can either be client or server side, no preference.
What I'm trying to accomplish is a user would type in a item number and quantity into two textboxes. Then they click add and it would add it to a list on the screen, this would sort of be like a shopping cart. How would I go about doing that?
With jquery:
var text = $("#id1").val() + "-" + $("#id2").val();
What I'm trying to accomplish is a user would type in a item number and quantity into two textboxes. Then they click add and it would add it to a list on the screen, this would sort of be like a shopping cart. How would I go about doing that?
With jquery:
var text = $("#id1").val() + "-" + $("#id2").val();
$("id3").val(text);
So it's easier to be done with jquery than with MVC?
So it's easier to be done with jquery than with MVC?
You are still using Mvc. What Andrei suggested is to make the computation on the client side without wasting a post to the server.
Now if you want to build a a list of all items bought, I suggest to use a knockout.js grid. This way you can easily do everything on the client side. This is an exaple of implementation of a shopping chart with knockout.js: http://knockoutjs.com/examples/cartEditor.html.
So it's easier to be done with jquery than with MVC?
You are still using Mvc. What Andrei suggested is to make the computation on the client side without wasting a post to the server.
Now if you want to build a a list of all items bought, I suggest to use a knockout.js grid. This way you can easily do everything on the client side. This is an exaple of implementation of a shopping chart with knockout.js: http://knockoutjs.com/examples/cartEditor.html.
MasterV23
Member
113 Points
318 Posts
Add TextBox item to List?
Feb 05, 2013 07:24 PM|LINK
What I'm trying to accomplish is a user would type in a item number and quantity into two textboxes. Then they click add and it would add it to a list on the screen, this would sort of be like a shopping cart. How would I go about doing that?
It can either be client or server side, no preference.
ignatandrei
All-Star
134913 Points
21619 Posts
Moderator
MVP
Re: Add TextBox item to List?
Feb 05, 2013 08:03 PM|LINK
With jquery:
var text = $("#id1").val() + "-" + $("#id2").val();
$("id3").val(text);
MasterV23
Member
113 Points
318 Posts
Re: Add TextBox item to List?
Feb 06, 2013 04:57 PM|LINK
So it's easier to be done with jquery than with MVC?
francesco ab...
All-Star
20912 Points
3279 Posts
Re: Add TextBox item to List?
Feb 06, 2013 06:39 PM|LINK
You are still using Mvc. What Andrei suggested is to make the computation on the client side without wasting a post to the server.
Now if you want to build a a list of all items bought, I suggest to use a knockout.js grid. This way you can easily do everything on the client side. This is an exaple of implementation of a shopping chart with knockout.js: http://knockoutjs.com/examples/cartEditor.html.
You can start from it . ...However, you need to study knockout.js before...http://knockoutjs.com/documentation/introduction.html
The other option being to create a new grid row whose input fields have the "right names" according to the theory explained here: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
However I find that the first solution is easier and more flexible.
Mvc Controls Toolkit | Data Moving Plug-in Videos
MasterV23
Member
113 Points
318 Posts
Re: Add TextBox item to List?
Feb 06, 2013 07:12 PM|LINK
Thanks for the suggestion.