Compare two int columns in SharePoint list - javascript

I´m doing a course catalog app for sharepoint. And i have a list called Courses.
in that list i have two columns called: seats and FreeSeats.
When you make a new course the boss decide how many can apply to the course.
So for ex: 5 seats.
When the Fifth person apply there most be a stop.
So i thought if i have the column FreeSeats, it can count up everytime someone apply. And when it is the same as the column Seats it will NOT be able to apply.
So i guess i need some sort of count that add 1 everytime someone apply to the FreeSeat column. And in a if loop check if the value of freeSeats are smaller than Seats, you can apply. If its bigger than Seats it will come a stop message.
Someone have any idea how a code like this looks like? I have never done this before.

Since your new to this I would advise you go through this MSDN tutorial.
It outlines how you would do some basic CRUD functionality in a SharePoint app.
You can then adapt it for your particular purpose. This is how I started out :) good luck. Ignore the fact it mentions Napa the app structure should be similar in VS
MSDN SharePoint CRUD in App
Cheers
Truez

You can actually set this up without any code by creating a list of Free Seats with Titles ranging from 1 to #. In your signup lists you would create a lookup column for each course that points to the corresponding list of free seats and select the "Enforce unique values" option. That way, when a user signs up for the course, they must select one of the free seat values you have created, and cannot sign up for a value selected previously. You can use a workflow to update a list elsewhere to give you your signup counts for tracking if you wish.
To do this programmatically you would need a workflow or event receiver that counted the total number of list items with a Free Seats value selected and then remove the contribute rights for the list that people are using to signup. There is no other way to stop people from adding a new item once your quota is satisfied.

Related

Way to update specific values in Bootstrap cards

I apologize for the amateur question here, however, I am experiencing some issues with a quick demo website I am creating for a friend.
The purpose of the site is to take the total of all "credit card values", and then divide it by the total amount of "points" there are to arrive at the "points per dollar"
Once that is done, I'd like to multiply the "points per dollar" by the total amount of "points" that are specified in the dropdown menu by the user, and then update all of the cards that have something selected to be the proper math with their point values.
I've successfully done all the math and created functions, but I am unsure how to actually apply it to the specific cards that need it.
I've created functions to do the math, and update the header numbers, just not apply it to the respective cards.
My code can be found here
My website is running on an express.js server with e.js as the templating engine, with bootstrap and jquery.
Any suggestions/help would be very much appreciated.
Easiest way to do this is to assign a unique id to each card so that you can write the corresponding data.
Then you can simply do something like:
$(`#${id} .whatever-class-name-for-points-element`).html(points);
It's a bit hard to tell what's going on in your code since it's not a minimum, reproducible example, but assuming you're trying to write one "points" value per employee, you could add id="<%= sm._id %>" or similar to each employee card.
FWIW, you probably want to use the id higher up (like on the card) and then use a data attribute (e.g. data-id="<%= sm._id %>") on the input.
Happy to give you further advice if you create a working, minimal CodePen/CodeSandbox/etc.

Multiple items. One sold. One PayPal Buy Now button for other items.

I am new to webdev and looking for suggestions.
Basically I am planning to use an image map to sell some items.
Each image contains up to 100 items. User can simply click on what's needed and from that point I need to figure what will be the best option to checkout.
The easiest method and obviously not smart will be to create 100 paypal buy now buttons and basically place each button for each item.
Cons - time consuming and space wasting because I will have about 100+ image maps.
Target is to have 1 checkout page which will know where the user came from and what he is actually willing to buy and somehow connected to PayPal Button.
Price for all items can be the same, no shipping price (it will be free) and no taxes. I don't want to have registration on the site.
Any ideas, maybe examples...?
HTML CSS JavaScript?
p.s. I found some topic about dynamic item name in paypal but I am still lost.

Button to open new page and auto fill some form elements

I sell a tremendous number of products that require finance of one kind or another. I also use 8 different lending sources for financing. Problem is that each lender works with certain product types and ages, etc. I can not use a generic application form due to the differences in each lenders requirements. I have added APPLY NOW Button(s) to each individual product but cannot use simple "goto" link.
Example(s):
Customer 1 views product ID#20, unit is 20 years old and only one particular lender will work.
Customer 2 views product ID#55, unit is brand new and all will work with it, but I send all new products to one lender in particular.
Apply Now Button is always the same image, but I need for the button to open the application page specific to that product, and auto fill the input fields such as Vendor Name, Product Name and Description, Price, Etc as most customers are unfortunately lazy and simply won't do that once they have been taken away from the product page. I figure I will need to code the button individually based on individual products to open the correct application, but want all to fill in the information. All items for AutoFill are stored in the Store Database as well as the Vendor (Store) Info.
Maybe I am in the wrong area or simply missed the answer somewhere else, but I am getting snow blind trying to find the answers...even a point in the right direction would help.
It sounds to me like you need to link the product with a lender type, this would make it easier to grab lander data and auto populate the form fields when the page loads. This way you would not need to change the "Apply Now" link.
In short I would suggest creating a link table between product/product type to the lender table.

Display related drop-downs using javascript

I have 3 drop-down boxes containing values of age, sport and relationship and all elements of them are loaded when we open the webpage.
Age = [0-10, 10-20, 20-30, 30-40]
Sport = [Soccer, Tennis, Golf, Chess]
Relationship = [Son, Brother, Father, Friend]
Now, elements of all three are inter-related with a mapping. For example, someone in age 20-30 can be a son, brother OR a friend; and can play soccer, tennis OR chess.
I want these drop downs to be dynamic, i.e, on selecting any value of any drop-down, the related options are displayed in the other two drop-downs. Shouldn't be an ajax call I think, since the all the fields are already loaded on the client.
Can anyone please tell me how can this be done in HTML using javascript(or any other way)? Any help would be great. Thanks.
U need to push the java script in this code. Which format you use. I will send the answer in your question with code

How to create an N:N relation editor in web page?

I have to create a small "who does what" web application for incoming letter routing:
there is a relatively long list (about 600 items) of employees;
there is a short list (about 5 items) of tasks;
when assigning a task to an employee, due date must be specified;
As a result, i need a list (sequence of items matters in this case, since the first employee in the list is considered the "main responsible person"):
John Smith - write a response letter - 20.01.2010
Frederica Minoso - review the incoming letter - 18.01.2010
Robert Geer - review the incoming letter - 18.01.2010
If we had, say, 10 employees, the design would be quite easy - a drop-down list of employees, a drop-down list of tasks, a date picker for due date, a "Add to list button"
Like this alt text http://naivist.net/tmp/layout.jpg
And of course, I would add a result list with "move up"/"move down" buttons besides it.
However, a drop-down list of 600 items is obviously too much; this means that some user searching by name, surname, department must take place.
I am skilled enough to technically create the application (JavaScript, jQuery and ajax requests being my friends), but the trouble is - how to design the interface of the web form so that the users would understand what exactly they are doing? How to lay out the items in form? What to show in the beginning, what to hide?
Maybe there are there some modern UI form patterns I could use here? For instance, maybe a text box where user can type in and auto-suggest with closest matches drops out?
Maybe some draggable/droppable pattern can be applied (for instance, after you have entered user's name, you drop it on an appropriate task)? How easily do users typically adopt to such non-standard interfaces?
To state a question - how do people typically solve this kind of data input problems? Have you seen good examples of this somewhere on the web? Tell me, because I can't think of any right now.
Sorry, there are many questions and many of them are discussable. Should I mark it as "community wiki"?
As soon as I saw the problem, I thought AutoComplete. Since you thought the same, it is probably the obvious solution to the problem. The "To" field of emails has the same issue - how to select that one person from 1,000s of contacts.
Yahoo has some good accessibility considerations to be sure that the AutoComplete field works in a manner that is obvious and consistent with typical behavior.
Since the task contains 5 items, drop downs are acceptable. The recommended upper limit for drop downs is 7 items, so you are within the limit. One suggestion would be to end the tasks with "by" or "on" so that the line reads like a sentence - John Doe writes a response letter on 22/01/2010. Also, including a little visual aid in the drop down could increase conprehension in some situations.
To begin with with, I'm not sure I agree with the non-standard interface part. I suppose it depends on who the users actually are, but I would definitely say that that kind of text box/auto search functionality is becoming very standard from airline booking forms to search engines.
About the selection method, I would go for the text box method, so that when a user types in text a search starts the results of which are displayed in a drop down. The search should of course search both surnames and first names with some kind of intelligent regex at least.
On top of that I would still add a selection field, maybe not a drop down but perhaps a list box that contains all the employees, possibly with options to order the names by surname or first. This would be for those who don't know the spelling of a persons name, or can't quite remember the name.
Otherwise the layout you have there seems to work for me. I wouldn't play around with dragging and dropping anything. This of course creates a nice feeling to it, but is way more unclear on what should be done to assign the tasks. If you find yourself writing instructions on how to use the thing then you've gone overboard.
The other thing that I thought of would be to have an appleish menu where you have an empty list at first and when you click on the list, the input fields appear. The problem with this is that since the UI doesn't have indication on what you should do to add stuff to the list, people are easily left baffled.

Categories