Expand my Community achievements bar.

Resetting an Image Field

Avatar

Level 1

Hey everyone,

I have created an interactive form in Adobe Designer 7.0 for my company with text fields and two image fields.  After the form had been filled in and the images added, the user has the option to submit, print or reset.

Everything works perfect except when the reset button is clicked, only the text fields are cleared and the two images remain.

How can i get it so that the whole form is reset?

Thanks in advance

Ryan

10 Replies

Avatar

Level 10

Hi Ryan,

After your reset script, include the following javascript:

imageField1.rawValue = null;

imageField2.rawValue = null;

Hope that helps,

Niall

Avatar

Level 1

Thanks Niall,

I am quite new to this and am not familiar with javascript at all.  I have created the form so far only using the text and image fields available to me in the designer 7.0 library.  Are you saying i will have to add the string of code that you provided in the XML source tab myself?  If so, could you please show me how it should be entered.  Im a little out of my depth with this so any help would be great.

This is the what i think the reset script is.... i may be wrong, if it is, how is the code you provided added to it?

Thanks

  <field xmlns="http://www.xfa.org/schema/xfa-template/2.2/" h="6mm" name="ResetButton1" w="28.575mm" x="171.45mm" y="260.35mm">
            <?templateDesigner isResetFieldsObject true?>
            <ui>
               <button/>
            </ui>
            <font typeface="Myriad Pro"/>
            <caption>
               <value>
                  <text>Reset Form</text>
               </value>
               <para hAlign="center" vAlign="middle"/>
               <font typeface="Myriad Pro"/>
            </caption>

Avatar

Level 10

Hi,

No, you should rarely have to go into the XML Source tab (sometimes it is handy to make changes here, but certainly not to put in code).

In LC Designer there is a "Script Editor" window. It is positioned at the top of the screen (just below the menu and toolbars). If you don't see this then you can make it visible from the Window menu or pressing Control+Shift+F5.

When it appears it may only be one line high, which is not very useful, so you can drag the bottom bar down to make it bigger.

Screen shot 2009-11-22 at 08.54.25.png

You can insert script directly into the script editor. For example just select the object (reset button) and the script editor becomes available. You have to select an event that you want to assign the script to, for example the click event. You also need to select a language (javascript or formcalc) and where you want the script to run (client or server). The example I have uploaded is JavaScript and runs at client.

When you drag the reset button onto the form and look in the click event, you will see that it already contains javascript, you can add your additional script under that.

Good luck,

Niall

Avatar

Level 1

Hi Niall,

I have have followed your instructions to the best of my knowledge but still cant seem to get it to work.  I have attached a screen capture of what im doing.  As i said before im very new to this so if you could point out where im going wrong that would be great.

Thanks


Ryan

Avatar

Level 10

Hi Ryan,

Both files are queued, so if you could reply and click the camera button above the message window and insert the screen shot.

Niall

Avatar

Level 1

I cant insert an image for some reason.

When i click on the reset button on the form, the code in the script editor looks like this -

----- form1.#subform[0].ResetButton1::initialize - (JavaScript, client) ----------------------------

1xfa.host.resetData();
2imageField1.rawValue = null;
3imageField2.rawValue = null;

Thanks

Ryan

Avatar

Level 10

OK,

It looks like the script is in the initialize event and not the click event. The script looks good, so I would just cut it from the initialize event and paste it into the click event. You can view different events by selecting from the dropdown.

Hope that helps,

Niall

Avatar

Level 1

Thanks for all your help so far, but im still not having any luck getting the images to reset.

Would it at all be possible to email you a copy of the file to have a quick look at incase im missing anything.  If not, its not a problem, i appreciate all your help so far.

Avatar

Level 10

Hi,

Sent you a private message with my email address. I am sure we can sort this out when you send the file.

Niall

Avatar

Level 10

It looks like you're adding line numbers manually - remove the 1, 2, and 3.

You can turn on line numbers in the script editor by right-clicking in the editor and selecting "Show Line Numbers". They're not part of the script.