Javascript link to a form field
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 8
- Joined: Fri Jul 24, 2009 4:02 am
Javascript link to a form field
I want to invoke the javascript function 'onclick' if the form field say textarea is clicked.Please help me on the same.
0 x
-
- Moderator
- Posts: 184
- Joined: Tue Sep 11, 2007 8:58 am
Here are the steps required to achieve this:
1. Add the following to HTML++ of your form:
2. Define the Textarea field as a label field and add something like this as it's label (adjust rows and cols to suit your requirements):
Note that onclick must issue an externalSubmit() for the form to know of the click.
3. If you wish the form to detect a click in the above field, add a control field to the bottom of the page, then add the following fpl to its validation event.
I hope this helps.
Hovik Avedian
Ebase Support
1. Add the following to HTML++ of your form:
Code: Select all
<script language=javascript>
function setuservar3( fieldValue1) {
for (i=0; i<document.RW.elements.length; i++) {
if (document.RW.elements[i].name == '$USERVAR3') {
document.RW.elements[i].value = fieldValue1;
break;
}
}
}
function externalSubmit () {
if (validate()) {
document.RW.nextPageFlag.value=1;
document.RW.submit();
}
}
</script>
Code: Select all
<tr>
<td valign='top' class='ufsflDEFAULT' width='51%' colspan='1'><label>Comments</label>
</td>
<td valign='top' colspan='2' class='ufsfeDEFAULT ufsfgb2DEFAULT'><span class='ufsfeffDEFAULT'><textarea rows="3" cols="30" class='ufsfeffDEFAULT' onclick="setuservar3('XYZ'); externalSubmit();" ></textarea></span>
</td>
</tr>
3. If you wish the form to detect a click in the above field, add a control field to the bottom of the page, then add the following fpl to its validation event.
Code: Select all
if [$USERVAR3 = 'XYZ']
set $USERVAR3 = ''; // clear it for the next time
message 'User clicked in the Text Area field';
endif
Hovik Avedian
Ebase Support
0 x
-
- Ebase User
- Posts: 8
- Joined: Fri Jul 24, 2009 4:02 am
I can detect the onclick event with the mentioned steps, however if there is any mandatory field before this text area , javascript popup comes up 'say this filed must be entered' when i click the textarea.
Is there any way so that this mandatory field checks are not invoked when i click the field?
Also i am not able to invoke the control field fpl.I have created a field and changed its property to 'Control Field' then i have pasted the below fpl in the script and added to the validation event of the field.Is this the right way?
Is there any way so that this mandatory field checks are not invoked when i click the field?
Also i am not able to invoke the control field fpl.I have created a field and changed its property to 'Control Field' then i have pasted the below fpl in the script and added to the validation event of the field.Is this the right way?
0 x
Who is online
Users browsing this forum: No registered users and 43 guests