This topic is locked

Show/Hide Fields

6/13/2007 2:13:04 PM
ASPRunnerPro General questions
S
s179999 author

AspRunner 5.0
Need to show/hide fields depending on another fields value.

Is this done in the html template or the asp pages and how do you do it?

J
Jane 6/14/2007

Hi,
where do you want to hide field value? Do you want to use JavaScript event for that?

Please give me more detailed description of what you need to achieve and I'll try to help you.

C
chris 7/13/2007

I might be interested in this solution, javascript is fine, based on the value of 'Testing required'. if yes, it should allow at least three or more fields be able to used otherwise they are greyed out or set to readonly.

Thanks,

Chris.

J
Jane 7/16/2007

Chris,
where do you want to hide field value (add, edit, view pages)?
To hide some filed on the add/edit pages using JavaScript you need to edit generated files manually. You should be familiar with JavaScript for that.

Here are some helpful links:

http://www.w3schools.com/htmldom/prop_style_display.asp

http://www.devx.com/tips/Tip/13638

cagleyleslie 9/26/2007

Hi Jane. I am interested in learning how to do this. I don't know which pages to edit, however. On my Add and Edit pages, there is a dropdown list. The choices are Green, Yellow, Red, and EAR. If the user selects EAR, I would like 3 other fields to appear. Otherwise, if he chooses Green, Red, or Yellow... those 3 other fields remain hidden.
So I can add this in the head part of the templates/..._add.htm and templates/..._edit.htm pages:
<script>

function hide()

{ document.getElementById('depend').style.display="none" }

function show()

{ document.getElementById('depend').style.display="block" }

</script>
And I assume I can add this for the onload event: body onload="hide()"
But where do I put the 'onclick' bits for each of the choices in the dropdown list? I need to put these somewhere:
onClick="hide()"

onClick="show()"
And then I need to add the ID for the fields I want to toggle between showing and hidden (based on the user selection from the dropdown list):
id="depend"
Where would I add that?
Thanks!!

J
Jane 9/27/2007

Hi,
to add onclick event edit BuildEditControl function in the generated include/commonfunction.asp file.
To add ID for the fields edit your page on the Visual Editor tab:

<TD width=250 id="depend">{build_edit_control field="FieldName" mode="add" value=$value_FieldName} </TD>

cagleyleslie 10/4/2007

Hi,

to add onclick event edit BuildEditControl function in the generated include/commonfunction.asp file.
To add ID for the fields edit your page on the Visual Editor tab:


Hi. You say to edit the BuildEditControl in include/commonfunctions.asp. I am using ASPRunner 5.1, and I don't see where in the BuildEditControl function that I add my code. In previous versions of ASPRunner, I made a similar edit in the BuildEditControl section in the _aspfunctions.asp page:
BuildEditControl =""

if sFieldName="Price" or sFieldName="Quantity" then

onchange = " onchange=""UpdateSum();"" "

end if

Select Case sFormat

Case EDIT_FORMAT_TEXTFIELD

BuildEditControl = "<input type=text name=""" & sFieldName & """" &


GetEditParams(sFieldName) & " value=""" & sDefault & """" & onchange & ">"
But the _aspfunctions page and the commonfunctions page are both different in ASPRunner 5.1. Where exactly do I make the edit in the new version of ASPRunner? Thanks!