Expand my Community achievements bar.

JavaScript does not work when bound to XSD, but fine when "normal" any ideas?

Avatar

Former Community Member
All,



Hopefully someone can help or respond.



Imagine:

Form (contains subform)

Subform (contains a numeric field and a button)



Button adds an instance of the subform:

//code in Click

_Subform1.addInstance(1);

xfa.form.recalculate(1);



Field should incrementally raise number by 1 from the previous

//code in Calculate

var myNewID=this.rawValue +1;

this.rawValue=myNewID;



Without binding, I can click the add button. Another field displays above with the number +1 higher. I need this since I need some unique IDs for each instance. If I click 4 times the fields come onto the screen with the numbers. For example (read across):



Box1 Box2 Box3 Box 4

1 -- -- -- <-- on first click

2 1 -- -- <-- on second click

3 2 1 -- <-- on third click

4 3 2 1 <-- on fourth click



When I bind the data to $record.match.left[*].id here's what happens:



Box1 Box2 Box3 Box 4

1 -- -- -- <-- on first click

2 1 -- -- <-- on second click

3 3 3 -- <-- on third click

4 6 6 6 <-- on fourth click



The next time would be 5,10,10,10,10 then 6,15,15,15,15,15 etc.



So, as you can see, it increments the first box by one, but then adds what box 1 and 2 were together and uses it for all the remaining boxes.



I did try using different code with a document variable but what I'd get was 1, 11, 111, 1111 (yep, couldn't seem to turn that string into an integer).



Does anyone have any idea how I can make this work? It should be very simple to mock up. I'd totally appreciate it.



Have a great weekend,

Lisa
4 Replies

Avatar

Former Community Member
Lisa,

Try making the following change:



var myNewID= parseInt(this.rawValue) + 1;



This will force it to add the two values as integers rather than strings.



--

Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com

Avatar

Former Community Member
Thanks, Justin -- that gets me much closer! (ParseInt /sigh).



The issue right now is the top field retains the correct values, but the rest go away. I may try to look in my temp files, providing I haven't completely deleted them and try to find my counter script which I placed on the button to add another subform instance.



I so appreciate your response! tytyty (^-^)

--lisa

Avatar

Former Community Member
lisa_j_richards@adobeforums.com wrote:

> Thanks, Justin -- that gets me much closer! (ParseInt /sigh).

>

> The issue right now is the top field retains the correct values, but the rest go away. I may try to look in my temp files, providing I haven't completely deleted them and try to find my counter script which I placed on the button to add another subform instance.

>

> I so appreciate your response! tytyty (^-^)

> --lisa



What specifically are you trying to accomplish? I might be able to recommend a better approach.



--

Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com

Avatar

Former Community Member
Wow, that would be more than super :). I think I've just tried this way to many times and just keep making it more complex than it really needs to be. The frustrating thing is that I know this is really simple stuff, but I'm sure my syntax is just off somewhere :(.



Here's what I'm trying to do with this piece. I'll take out everything but the need to knows.

Imagine a repeating subform. This subform contains 2 fields bound to "LeftID" "RightID". These values will be the same.

There is an "add a subform" and a "delete this subform" button.



In the first instance, each LeftID and RightID field would say "1". When the user clicks the "Add" button, the next subform that appears below would contain the number "2" in the LeftID and RightID fields. Likewise when they use the "Delete" button it would delete that number.



I don't need to have perfect numbering going down the page, but I do need each subform to have a unique number. What I was really hoping to find out was if the .index held a numerical value and populate with that, but of course I couldn't get that to work.



I hope that is enough information to go on. If you need more let me know and I'll provide you with anything you need.



Thank you thank you again,

Lisa