- Tue Jan 04, 2011 4:15 am
#10881
Hi all,
Hope someone can help me, my js knowledge is quite limited and ive been on google all day looking for answers..
I want to have a button on my form that will allow users to hide and unhide certain fields on the form that are relevant.
I can do it the painstaking way.. by simplye switching back and forth from view to the editor.. But this form has about 50 fields that will need to be programmed for this.. and i have a feeling the client will ask me to add many more.. so ive tried to come up with a way to do it quickly..
The way i understand to hide and unhide via js.. is to use the following code:
So i have been trying to use a window.prompt and with variables in my script to be able to look at my form from the preview, click the button, put the changing field name and test how many.parentNodes it has without having to switch everytime back to the js editor.. if i could get this working and figure it out it would save me fortunes of time for this project and future projects of PM as well..
Any assistance would be very very appreciated
Thanks in advance,
Lawrence
Hope someone can help me, my js knowledge is quite limited and ive been on google all day looking for answers..
I want to have a button on my form that will allow users to hide and unhide certain fields on the form that are relevant.
I can do it the painstaking way.. by simplye switching back and forth from view to the editor.. But this form has about 50 fields that will need to be programmed for this.. and i have a feeling the client will ask me to add many more.. so ive tried to come up with a way to do it quickly..
The way i understand to hide and unhide via js.. is to use the following code:
Code: Select all
and to unhide:
getField("MyField").parentNode.style.display='';
Code: Select all
Now the problem with this is depending on what field it is.. the parentNode will be different.. for example a text box may have .parentNode.parentNode, and a dropbox may have a .parentNode.parentNode.parentNode while a Main Title might have only one .parentNodegetField("MyField").parentNode.style.display='none';
So i have been trying to use a window.prompt and with variables in my script to be able to look at my form from the preview, click the button, put the changing field name and test how many.parentNodes it has without having to switch everytime back to the js editor.. if i could get this working and figure it out it would save me fortunes of time for this project and future projects of PM as well..
Any assistance would be very very appreciated
Thanks in advance,
Lawrence