Billing Software for Shops using Html and Java Script.
Do you want to know how to get value of a selected item in java script ?
If you want to know how to get the value of a selected item from a multiple choice list you are in the correct place to learn. You must have to read the post at least once. Value has been collected from the form using elements. To know further, continue reading. Have a nice day.
Create Menu Item
You have to create a form inside that you can use whatever type like checkboxes or radio buttons or any other you want, here I am using select tag choice list for both Multiple and single options. When you use Multiple in the select tag you can select Multiple options and the default one is to select a single option. Onclick event pick() is to show the selected options from the menu. For that you have to create a text view to show the selected list of Items.
Create Text Area
Text area has been created using textarea tag widely used to get information from users like plain text and Total Cost button is to trigger the event cal() to calculate the total amount of Item purchased from the menu and Clear button is used to clear the text area box using onclick event clr().
Pick Items From Menu
Pick function is used to show the selected Items from the Menu in the textarea. Variable z has been created to store the value selected from the menu and add menu items. Here f1 is the form name and elements[] which is used to select a particular field from the form and always elements start from 0. Here select tag named "s1" = element zero, select tag named "s2" = first element, select tag named "s3" = second element, textarea = 3rd one and the total cost and clear button are the 4th and 5th elements. First for loop is to get the selected items from the first 3 elements and the Second for loop is to know how many items are there in each element. For Example To know how many options are there in the first select tag. And the if is used to check whether the option is selected, if true it will get the value from that element and stored or added to the z. Atlast you have to show the selected options in the textarea with elements, As I mentioned earlier the 3rd element is textarea.
Calculate Total Amount
You have to get the value of each selected Item from the menu using the same procedure as above in the pick() function. Once you get the values of the selected Items you can get the position of Greater than(>) symbol before the price using indexOf method, it will get the position of the string. From that you can extract the price using the substring method, it always starts from the given number and ends before the ending number. After that you have converted the String into Integer. Here m is a global variable that stores the value of z.
Clear Textbox and Reset Form
As I mentioned earlier textarea is the 3rd element in the form. Once the clear button is clicked textarea and other form fields will be cleared.
Program
Welcome To McDonalds
Here is the link for Mark Sheet Result Page using Html and Css.
0 Comments