Logic Error In AcroJS - Subtracting Instead Of Toggling
Feb 4, 2011
Putting some javascript into a pdf file and can't get this to work out right.
Basic setup:
Field X = checkbox;
Field Y = numeric input field;
Here's what should happen (increment is toggled):
Y has a value. When X is checked, Y is increased by 5. When X is unchecked, Y goes back to its original, unmodified value.
Here's what really happens (increment is subtracted):
Y has a value. When X is checked, Y is reduced by 5. When X is unchecked, Y is reduced by 5 again. Anytime X is clicked on, Y is reduced by 5 yet again.
How to create a function that would allow me to add to or subtract from a maxvalue, and thankfully I got help regarding that. However, something's got me stumped for the past few weeks that I still can't resolve...
This is the relevant code:
As it stands, it works as long as the total value is less than or equal to the limit (for advantages it's 15, for disadvantages it's 10). However, the moment it goes past the limit -- for instance, if you change Antisocial's value from 2 to 7, or if you add several additional checkboxes with any values -- the whole thing starts going crazy; specifically, maxvalue doesn't revert to 40 when the all the checkboxes are unchecked.
What I'd want to happen is that the user cannot select or apply advantages or disadvantages if the maximum advantage is greater than 15 or the maximum disadvantages is greater than 10.
I'm thinking that a button for adding disadvantage points to/subtracting advantage points from the maxvalue (that becomes disabled if the user goes past his limit on advantages/disadvantages) is useful at this point, but I'm really stumped on the implementation of the idea. An alternate idea of mine is that all other advantage/disadvantage checkboxes would become disabled if their value is greater than the remaining number of points, but I don't know how that is possible either.
How to subtract totalgift if my condition of donateamount is lesser than the totalgift trigger.
When the field is selected and the DonateAmount is trigger, I need to subtract the entered amount on the field selected to the TotalGift and put the field selected to zero "0" and TotalGift to original amount which is less than the amount entered on the field selected. I have some code that I created but it doesn't work. My initial javascript to calculate all the total is below assuming that DonateAmount is already selected = 25:
Below is what I am trying to do but it doesn't work. If the first input field is selected and user enter amount greater than the TotalGift, alert will pop-up then and the amount entered by the user automatically added to the TotalGift. So what I wanted to do is to subtract the amount entered to the TotalGift so it will go back to the original amount before the addition occurs. I know it is possible but I just can't get the right code.
My html code below which I have 18 input fields but all of them only optional wherever the user wants to input number. I will only include some here. Code below works, please ignore any missing code. I just need the calculation code to work.
I am having difficulty with creating a function that uses a For Loop to pull in two unknown variables and subtracting the first number from the second number. The subtraction occurs but I always get a negative number. This exact same function works correctly when adding but does not when I use it for subtracting to values. Here is what I have so far:
function calcDep1() { dblTotal = 0.0 for (i=8;i<=9;i++)
[Code]....
I have worked with it for several hours and also changed the equation to reflect dblTotal = dblTotal - dblValue but it still evaluates to a negative number. The two test values I used are 100 - 50 which should equal 50 but the answer always comes out to -150.
I have a custom order form that will add up and show the total but I'm having trouble getting it to subtract the discount. What changes do I need to make to my javascript?
The form is here: [url]
This is the javascript I'm using which is also viewable in the source code of the above form:
I have writting all of my paging logic in javascript. It works pretty fine. Basically, I have created a gridview with full paging in javascript. Now, given a certain need, I am being advised to do my paging on the server.
My question: is there a performance cost by doing all my paging server-side (and cost benefit by keeping it on the client). Or, does it matter?
I want to create an image gallery like imageflow, but having tough time to figure out the way top, left, height and width are computed for each animation call.
I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an internal intranet application rewrite. This approach will definitely stir up hot debate from hardcore server-side Java folks who wants to do UI stuff even on the server!. Since I am pretty much known as the JS or UI Guy of the group, my Boss wants to hear the broad spectrum of PROs/CONs from each proponent.
Personally, I think Javascript/Ruby is a more productive language than Java.
My idea is simple. It is to convert most business logic to client- side javascript and have calls to server-side code restricted to user roles with data validation. Thats as simple as it gets.
Here are my list of arguments
1. True separation of UI logic from server-side data processing code (no more server code spitting out client-side code) 2. Better user experience with faster response 3. The whole web 2.0 thing (no page refresh) :) 4. Offload client processing from server therefore reducing network traffic (not really a strong argument is this?)
Keep in mind this is an internal app. Even if someone figures out the JS logic behind the page and try to hack the app by posting to Servlets, they will be restricted by their login role, and data validation will take care of any bogus data being submitted.
i would like to toggle between 12 separate divs (each of which contains a table that corresponds to a monthly calendar, if that helps you to visualize what i'm doing) when the corresponding link name is clicked. i've got it so that when the link is clicked, the div toggles between on and off states, but what i really want to do is replace the currently visible div with the new one. the code i've got to this point follows:
When the thing is first ran, IE displays alert saying "virtual" and successfully turns the wrap off. When I run it again, the alert still says "virtual"! It's like it doesn't save the settings but does apply them.
The default behaviour for a class selector is: "An element can have multiple classes; only one of them must match." Is there a class selector where you can use multiple classes and all of them have to match?
was wondering if it made sense to optimize the comparison order inside an if() statement if one of the comparison targets is a function call eg:
var a = true, b = function() {return false;}; if (b() || a) {...} if (a || b()) {...}
would the second statement run faster because it would theoretically never need to call b() in this situation? can the eval order be relied on? does this depend on the js engine/internal optimizations?
I am now trying to adapt this script to a section of my site where a user is able to answer questions with checking a yes or no radio button If the user checks a yes radio button then this toggles a slide animation which makes visible some content (another question and after that one a set of answers). Anyway, I am able to get this working for one question only.
Would you like a course of study involving works of art or antiques?and user selects yes radio button and the hidden div content is shown. However if you click yes again its hides (which i do not want) and if you click no it doesnt do anything when i want it to hide the content while the yes radio button makes it visible.So, was wondering if someone could take a look at my code and see if you can make any sense of why its not working as i hope it to (my javascript knowledge is incredibly limited and am learning at the moment).
there's a line in my Javascript program that makes a change in the appearance of an area of the screen. it is a game program, so there are a cascade of changes after the user makes a move. these are carefully sequenced and timed in a loop which contains the "action" statement
document.images[k].src = offGIF[currNode];
unfortunately, the *actual* screen updating appears to be 1) asynchronous and 2) faulty!
_asynchronou_s in that things change in the wrong order, as if each has its own thread and they run at random.
_faulty_ in that occasionally an area that would change from, say, picture1.gif to picture2.gif and back again (according to game logic) lands up showing picture2.gif. even though the internal game logic has it recorded (and i assume document.images[k].src would be correct, even though the screen is not) as picture1. so.
is there a way to wait or surrender control to the system until the program statement's intent has actually been rendered to the screen? something i can test to see if the unerlying system mechanism has caught up with all changes to document.images?
I've got this code to add bbcode into a wysiwyg rich text editor. Everything's working fine except when I want to add an image. The first time the script is run everything is ok, but the second time I get two image inserts, third time I get three and so on.
Here's the code: Code: $('#uploads tr').click(function(){ var filename = $(this).text(); var insert = '[img="'+filename+'"]'; textarea.value = textarea.value+insert; $('#images').hide(); textarea.focus(); });
So first time I click on '#uploads tr', I get [img="filename"], then if I type some more stuff and then add another image, I get [img="filename"] 'Some more stuff' [img="filename2"][img="filename2"], then I'll get three image tags, then four and so on. I can see that it's something to do with the line I've highlighted, but I can't see why, or how to change it.
I am trying to figure out if it is possible to add properties (or tie another variable) to a variable string? I believe it is limited to objects. I'll show you the code to help clarify what I am getting at:
function toggleKml(theKML) { if (theKML.toggleState == 1) { map.removeOverlay(theKML);
<input type="image" src="pause.png" onmouseover="src='pauseon.png'" onmouseout="src='pause.png'" onclick="togglePause()" id="pauseBtn"/> which changes from the play image to the pause image when clicked, using this function:
I have been banging my head against the wall on this one. I have a drop down list menu that when a value is entered I have
"onChange="this.form.copy0002.value=this.value"
which takes the value of the drop down and places it into a text field in a different section. I also need it to check a box on the same line that corresponds with auto populated field. Is it possible to do this. I'm assuming it would be " onChange="toggleChecked(0001check)" or some variation?
I have a form. When you click the checkbox, a text box appears. When you uncheck the checkbox, it disappears. This is all great, the problem is once these preferences are saved the user can go back to the form. Their data will be prefilled...if the checkbox is loaded as checked, it won't bring up the text area! You have to uncheck and recheck it.
I have a page with a number of divs on it. The number of actual divs is variable and is database dependent. Each div has a sequential id, e.g.:
<div id = "id0"> <div> <div id = "id1">
[code]....
Initially the first div's visibility is set to "display: block" and all the rest to "display:none". What I would like to be able to do is present the user with a series of links which when clicked would result in just one of the divs being displayed and the rest all hidden.
I'm going to have a webpage which will contain a number of tables. Some of these tables will have a number of rows where they have been set to not show by setting "display:none". Each of these tables will have a button beside it which when clicked will result in the 'hidden' rows appearing (or disappearing).I'm very much a beginner when it comes to javascript but can easily handle the above if it was just a single table row whose appearance was being toggled but it's likely to be any number of rows. I was wondering whether I should assign all the hidden rows with a particular class and in addition assign each actual table with hidden rows a unique id. Would that then allow me to pass both table id and row class to a javascript function which would then toggle the display of the rows. At this point I'm out of my depth