I'm having problems with some JS I'm working with. I'm trying to make a dynamic coverage calculator. Here is the URL of the JS engine I'm using: http://www.lutanho.net/diagram/diagram.js

Here is the code for the input frame:

<SCRIPT Language="JavaScript">
function Draw()
{
  parent.rd=document.inputform.rd.value;
  parent.frames[1].location.href="db_display.html";
  parent.thrw=document.inputform.product.value;
}
</SCRIPT>

Now here is the code for the display frame:

<DIV STYLE="position:absolute; top:0"></DIV>
<SCRIPT Language="JavaScript">
var i, x, y, xmin=parent.xmin, xmax=parent.xmax, ymin=parent.ymin, ymax=parent.ymax, rd=parent.rd; thrw=parent.thrw;
document.open();
var D=new Diagram();
D.SetFrame(60, 45, 460, 445);
D.SetBorder(-200, 200, -200, 200);
D.SetText("Ft.","Ft.", "y=f(x)");
D.Draw("#DDDDDD", "#000000", true, "y="+rd);
document.close();
Draw();
function Draw()
{ 
P=new Array();
document.open();
P[0]=new Pie(D.ScreenX(0),D.ScreenY(0),0,thrw,0,rd,"#ff6060");


}
</SCRIPT>

Note: the variable "thrw" is coming from a dropdown selector, with numbers as their value options. In theory, putting the variable in should product the same result...instead, it moves the pie slice over to the right a ways. Does anyone know why? any help would be greatly appreciated.
Thanks,

James

Recommended Answers

All 6 Replies

moves the pie slice over to the right a ways.

I may regret commenting without having looked at the code. Let me repeat: I haven't even glanced at the code.

However, having a pie chart look as though an actual piece of the pie is being removed is a display option of many pie-chart generators; you might check the default presentation settings.

Haha I know what you mean but I don't think so. See, it worked perfectly before I used a variable to input the number from another frame. When I was just manually putting in numbers it was great. So, I'm not quite sure what's up.

it worked perfectly before I used a variable to input the number from another frame.

The snippets you posted aren't complete enough to test. Do you have a link to your page?

You refer to 'another frame': are the pages in the same domain? Have you made sure that all values are being received - and that no values/options are left undefined? Have you tried cooercing values to numbers? For example, thrw = +parent.thrw; ?

Perfect! All it took was changing thrw=parent.thrw; to thrw = +parent.thrw;

Thanks so much!

Perfect! All it took was changing thrw=parent.thrw; to thrw = +parent.thrw;

Thanks so much!

You're welcome. Remember to click 'solved'. And don't forget the up-arrow. :)

commented: Helped me tremendously on my Javascript problem. +3

Done ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.