How JustAnswer Works:

 
 
 
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
 
 
 
Ask TheDoctor Your Own Question
TheDoctor, Software Engineer
Category: Programming
Positive Feedback: 100 %
Satisfied Customers: 784
Experience: M.S. in Internet Information Systems
Type Your Programming Question Here...
TheDoctor is online now
A new question is answered every 9 seconds

Hi Atlprog I would like to request some additional amendments

Customer Question

Hi Atlprog

I 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.zip

Thanks.

Submitted: 11 months ago.
Category: Programming
Expert:  ATLPROG replied 11 months ago.


ATLPROG :

Hi

ATLPROG :

What exactly you mean by "you did for the orders form be modified for objects instead of arrays"

ATLPROG :

what object you are talking about

ATLPROG :

And about the second program i am afraid i won't be able to assist you with that

ATLPROG :

I will be back in around 1 hr

Customer :

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.

Customer :

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;}

Customer :

Anew instance would be:

Customer :

var bc = new Juice("Banana & Cola");

Customer :

var gh = new Juice("Ginger & Honey");

ATLPROG :

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.

Expert:  TheDoctor replied 11 months ago.

Hello. I would be happy to assist you with this request. I will reply with the modifications soon.

Customer: replied 11 months ago.

Thank you, XXXXX XXXXX go to sleep now but will check back tomorrow afternoon. Thanks for looking.

Expert:  TheDoctor replied 11 months ago.

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?c

I will have the other files to you soon.

Expert:  TheDoctor replied 11 months ago.

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?c

I 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.

Customer: replied 11 months ago.

Hi TheDoctor


Thanks for your help, these scripts are extremely useful; I've already learnt a lot already. Never underestimate the power of loops!

It would be great if you could briefly clarify a couple of things:

- in the FMA_queries.js file, why was it necessary to create a returnBoolean variable instead of just return as true like the other functions below it;


- in the fma.js, how does the function fnCalculate() know where to check whether the checkbox was checked? i.e how does the html form connect with this.JuiceName?


if (document.getElementById(this.JuiceName).checked)


Thanks again.

Expert:  TheDoctor replied 11 months ago.

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.

TheDoctor, Software Engineer
Category: Programming
Positive Feedback: 100 %
Satisfied Customers: 784
Experience: M.S. in Internet Information Systems
TheDoctor and other Programming Specialists are ready to help you
Customer: replied 11 months ago.

Hi TheDoctor


Sorry to bother you with more queries but I'm still studying the loops. I hope they are not too time consuming for you.

Could you tell me why:


-in FMA-queries.js, in the for loop why is i < detailsArray.length and not i=< detailsArray.length?


- is the reason that ("result"+(i+1)) in the IF statement because the Array starts at 0 so the 'result' value has to add 1 to compensate (because the 'result' values begin with 1)?


-what does the ! mean in the line if(!validateArray[x]).



Expert:  TheDoctor replied 11 months ago.

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 23

When 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 put

if(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.

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
< Last | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
 
 
 

Meet The Experts:

 
 
 
  • ATLPROG's Avatar

    ATLPROG

    Computer Software Engineer

    Positive Feedback:

    99.8 %

    Satisfied Customers:

    7396
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
< Last | Next >
  • http://ww2.justanswer.com/uploads/SP/spatlanta2010/2011-6-23_12450_photo.64x64.gif ATLPROG's Avatar

    ATLPROG

    Computer Software Engineer

    Positive Feedback:

    99.8 %

    Satisfied Customers:

    7396
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Computer Software Engineer

    Positive Feedback:

    99.4 %

    Satisfied Customers:

    5551
    Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
  • http://ww2.justanswer.com/uploads/unvadim/2010-11-15_210218_avatar.jpg unvadim's Avatar

    unvadim

    Computer Software Engineer

    Positive Feedback:

    99.7 %

    Satisfied Customers:

    1147
    Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.
  • http://ww2.justanswer.com/uploads/lifesaver333/2010-10-17_191349_ls.jpeg lifesaver's Avatar

    lifesaver

    Computer Software Engineer

    Positive Feedback:

    100.0 %

    Satisfied Customers:

    944
    Several years of intensive programming and application development experience in various platforms.
  • http://ww2.justanswer.com/uploads/RA/rajivsharma086/2012-6-6_17128_displaypic.64x64.jpg Raj's Avatar

    Raj

    Computer Engg.

    Positive Feedback:

    98.8 %

    Satisfied Customers:

    857
    BE CS, 4+ Experience in Programming and Database (ERP)
  • http://ww2.justanswer.com/uploads/EH/ehabtutor/2012-8-2_202016_1.64x64.jpg ehabtutor's Avatar

    ehabtutor

    Computer Software Engineer

    Positive Feedback:

    99.2 %

    Satisfied Customers:

    787
    Bachelor of computer science, 5+ years experience in software development, software company owner
  • http://ww2.justanswer.com/uploads/eljonis/2010-01-06_130406_eljon2.jpg Eljon's Avatar

    Eljon

    Consultant

    Positive Feedback:

    99.4 %

    Satisfied Customers:

    590
    11 yrs of programming (PHP, WordPress, XSL, SQL, JavaScript)