Expand my Community achievements bar.

Clearing an image field

Avatar

Level 3

I have created an image field that a user can select via a checkbox.  The image field is hidden by default.  If the user clicks a checkbox the field becomes visible.  Clicking the field allows the user to embed an image. 

I am attempting to set a "clear image" action, but for some reason if I set the image field rawValue to null the image field disappears and will not come back.  The only command I am associating to the button is:

COPQImage.rawValue = null;

This makes the field disappear as if it was reset to hidden, and clicking the check box to attach an image will not bring the field back.  Is this a bug, or is there something else that needs to happen to an image field if you set it's rawValue to null?

5 Replies

Avatar

Level 3

Thanks Magus, but unfortunately it does not shed any light.  I am distributing a PDF, not using Form Server, and cannot use an image and URL as the intent is that the user will attach their own image of a graphic/chart/whatever.  This form will be distributed globally amongst varying organizations that have no central authority or server capability.

Avatar

Level 10

Hi,

I have an example here where you can have script in the click event that checks if the user is holding the Shift key. If they are, it clears the imageField: http://assure.ly/j1KdNq

Hope that helps,

Niall

Avatar

Level 3

Thanks Niall -

I have found your exmaples to always be very enlightening and helpful.  In this case, there seems to be an issue when you set two properties:

1.  You set the imagefiled to be hidden until a user requests it to be visible via a checkbox, button, etc, and hide it again it they opt to get rid of the imagefield (they change their mind)

2.  You set the imagefield to expand to fit in the X and Y axis

In my case users are attaching snapshots of graphs they need to support the text written in a textfield.  They may or may not require an image to accompany it, so I set the imagefiled to be hidden by default.  They check the "Attach image" checkbox, I setFocus to the imagefield, they select an image.  All good.  But if you set the imagefield rawValue to null to clear it, as you do in your example or with a button or a checkbox or any manner, and hide the imagefield again to clear it's layout space you cannot get the imagefield to come back.  I altered your code to hide 'myimage' with a checkbox, and set the layout to expland in X and Y.  Once the rawValue sets to null and myimage is hidden it will not come back.  If you do not set the layout proerty to expand it works fine.  But if you expand that imagefield to size accordingly rawValue = null kills the ability to have it come back once hidden.

Avatar

Level 10

Sorry for the delay,

I doubt that is the case. Can I suggest that you separate out the blocks of script into different events.

For example, place the set imageField rawValue to null script in the mouseUp event and the hide script in the click event. This way the first block of script will fire completely, before you hide the object.

Also use the JavaScript debugger to see if there is an error happening.

Hope that helps,

Niall