CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Make One Field Required based On Selection from Another Field

 



nickreidy
New User

Oct 2, 2017, 9:57 AM

Post #1 of 6 (1528 views)
Make One Field Required based On Selection from Another Field Can't Post

How to Make a Field Required based on A Selection from a Different Field

I have 2 fields. One is called request type, the other is part ordered date Request type is a drop down list, part ordered date is a date field

When a user selects from Request Type the value of Parts Request, how do I now make the Parts Ordered field required?

I can not for the life of me figure this out.


Laurent_R
Veteran / Moderator

Oct 2, 2017, 10:03 AM

Post #2 of 6 (1527 views)
Re: [nickreidy] Make One Field Required based On Selection from Another Field [In reply to] Can't Post

To me, the question is incomprehensible. Where dou you have two fields? In a Perl data structure within your program (say an array or a hash, or a combination thereof)? In an input file? If in an input file, then what kind of format?

Please give more details, or show some code, or both.


nickreidy
New User

Oct 2, 2017, 10:10 AM

Post #3 of 6 (1526 views)
Re: [nickreidy] Make One Field Required based On Selection from Another Field [In reply to] Can't Post

We use Perl for scripting of a proprietary system.

I have a field that is labeled Request_Type and has multiple choices. When the choice of "Parts Request" is selected, I would like to make another field named Part_Ordered_Date required.

This is a proprietary help desk system and all of the people that created it are gone. I am no Perl expert, but can write in SQL.

I tried if, then, else statements from SQL but it doesn't work.


FishMonger
Veteran / Moderator

Oct 2, 2017, 10:54 AM

Post #4 of 6 (1524 views)
Re: [nickreidy] Make One Field Required based On Selection from Another Field [In reply to] Can't Post

Is this a web app?

Can you post the code?


ogit2
Novice

Oct 4, 2017, 4:34 AM

Post #5 of 6 (1488 views)
Re: [nickreidy] Make One Field Required based On Selection from Another Field [In reply to] Can't Post

Hi

As per previous posts, there is not much info to go on. If you are using a web page, then the way forward would be JavaScript not Perl with onChange function changing properties of part ordered date or when submitting, checking the date and request type and posting a message.

Hope this helps.


(This post was edited by ogit2 on Oct 6, 2017, 2:55 AM)


nickreidy
New User

Oct 4, 2017, 6:51 AM

Post #6 of 6 (1485 views)
Re: [ogit2] Make One Field Required based On Selection from Another Field [In reply to] Can't Post

Thank you everyone, but it was figured out:

my $request_type_value = $entity->GetFieldStringValue($fieldname);
if( ${request_type} ne "" ){
$entity->SetFieldRequirednessForCurrentAction( "Part_Ordered_Date", $CQPerlExt::CQ_MANDATORY );
}
else {
$entity->SetFieldRequirednessForCurrentAction( "Part_Ordered_Date", $CQPerlExt::CQ_OPTIONAL );
}

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives