Hi AtlprogI would like to request some additional amendments to the form you helped me with before.The first is that the loop you did for the orders form be modified for objects instead of arrays.The second is a simple alert box that appears when a form has no errors and is submitted successfully.There are two html and two js files at the following link:http://wikisend.com/download/186402/Javascript_queries.zipThanks.
Hi
What exactly you mean by "you did for the orders form be modified for objects instead of arrays"
what object you are talking about
And about the second program i am afraid i won't be able to assist you with that
I will be back in around 1 hr
Hi, in the link there is a file (fma.js) that explains it. Whereas before there was an array called Juice ('juice1', juice2') etc I would now like to use a custom object to contain the juices e.g.
function Juice(name, price, qty) //Create a Juice object using the constructor function:{ this.juiceName = name; this.Price = 0; this.Qty = 0; this.fnCalculate = fnCalculate;}
Anew instance would be:
var bc = new Juice("Banana & Cola");
var gh = new Juice("Ginger & Honey");
Unfortunately, I am not able to assist you with your question, so I will open it to all Experts and if someone can assist you, they will post a reply here on this page (No need to create a new question). Best wishes.
Hello. I would be happy to assist you with this request. I will reply with the modifications soon.
Thank you, XXXXX XXXXX go to sleep now but will check back tomorrow afternoon. Thanks for looking.
Hello,Here is the link to the Juice project using juice objects. I also changed it to print out the GBP symbol rather than $ in the results.http://ge.tt/30DLENK/v/0?cI will have the other files to you soon.
Hello,With the second set of file, I simply altered it so that the popup works when everything is successful. I had to change a few things in the js file, but nothing else. If you wanted anything else done to these files, let me know.http://ge.tt/6qagKNK/v/0?cI hope you are pleased with my work. Let me know if you want anything changed.Please remember to rate my answer. It is the only way I receive credit for my work.Thank you so much for using JustAnswer. Have a great day.
Hi TheDoctor
You are very welcome.The first function uses a boolean because the detailsArray is passed in. That array contains both the first and the last name. Your function loops and check both the first and last name. If we simply returned true or false, it would never check the second field. As soon as a return is called, the function ends. However, if the first is false, and the second is true, we still want to return false. So waht the loop does is set the boolean to false if any of the fields passed in do not pass validation. It looks like this function was built so that it could validate a large number of fields, including things like address. Using this boolean, you can do just that.If you look at the html file for the Juice project, you will see that the id of the checkboxes is the name of the joice it is associated with. That way, we can refer to the checkbox by the object's JucieName.Thank you.
Hello,The i is used to reference the index of the array within the loop: detailsArray;In almost all programming languages, PHP includes, arrays always start at index 0.So if detailsArray.length returns 2, that means that there are two objects in the array. These objects exist at index 0 and index 1. This is why, in almost all code, a for loop will use < and not <=. If you did <=, it would try to reference index 2 and you would get an error for a referenced index that does not exist.For your second question, the answer is yes.Third question: In all modern programing languages the ! means not. So you could do:if($a != 23) //if $a does not equal 23When your variable is a boolean, you needn't type this out. You can use the not symbol, !, to check the inverse.typed out, this would be:if(validateArray[x] == false)if we did not put the ! symbol in front and just putif(validateArray[x])We would enter the conditional whenever validateArray[x] is true, and we would not enter the conditional if it was equal to false. However, we want the inverse of that. We want to enter the conditional when validateArray[x] is NOT true. Therefore, we can simply put a NOT in front of it:if(!validateArray[x])This is the most standard way of working with booleans inside of conditionals.