Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Dropdown list, required and Null

phpMyEdit General     Dropdown list, required and Null
Post new topic   Reply to topic    
 
ned@kelly.org.au     Joined: 08 Apr 2004   Posts: 22   Location: Mosquito Flat, Australia
Post Posted: 2004-09-14 02:03
Back to top  Reply with quote     

Hi All

This I hope is a simple question:

I have a field in a table that I want to be 'required' but appear empty when you first open the form, but not accept blank and be from a dropdown list.

at the moment this field looks like:
<code>

$opts['fdd']['client_on_tax_cd'] = array(

'name' => 'Client on tax CU Form',

'select' => 'D',

'maxlen' => 1,

'values' => array(' ','Y','N'),

'options' => 'ACV',
'required' => true,

'sort' => true
</code>

as the first value is ' ', this field looks empty when the form is opened but when you hit the Save button it doesnt come up with a warning saying that you must enter data into this field as its required as it accepts ' ', as a selection.

Is there a way to changes this so that the field is blank when opened, be from a dropdown list, and not accept blank as a selection?

Hope this makes sense

Cheers

Ned

 
debstar     Joined: 13 Sep 2004   Posts: 4   Location: UK/Australia
Post Posted: 2004-09-14 08:57
Back to top  Reply with quote     

ned@kelly.org.au wrote:

'values' => array(' ','Y','N'),

Ned


I haven't tried this so I'm just guessing / speculating but... have you tried getting rid of the space?
i.e.
'values' => array('','Y','N'),

Would that work??

 
ned@kelly.org.au     Joined: 08 Apr 2004   Posts: 22   Location: Mosquito Flat, Australia
Post Posted: 2004-09-15 01:25
Back to top  Reply with quote     

Thanks Debstar

but unfortunately '' doesnt work

the field looks and is blank but it doesnt come up with 'required field' warning

I was thinking about attacking this a different way

by instead of having the field blank ('',) style
having the first option appearing as 'default','Y','N' and having a trigger or something that comes up with a warning if the field has the text 'default' in it.

Has anyone done something like this before or got any other ideas? I've no idea how to start writing a trigger - anyone got full examples?.

cheers

ned

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-09-16 08:52
Back to top  Reply with quote     

try to use new 'js''regexp' option. see bug #161 and cvs documentation for more details. should work with dropdown as well, afaik.

 
ned@kelly.org.au     Joined: 08 Apr 2004   Posts: 22   Location: Mosquito Flat, Australia
Post Posted: 2004-09-20 05:02
Back to top  Reply with quote     

Thanks for the reply Michal

the 'js''regexp' worked fine on normal - text entry fields but I can't get it to work on dropdown lists

from the below code I would expect that if there it was empty(the first option) OR if the answer was Y or N then a JavaScript box would appear with the text from 'hint', but its just not happening, it accepts anything.

Code:

$opts['fdd']['client_on_tax'] = array(
  'name'     => 'Client on tax *',
  'select'   => 'D',
  'maxlen'   => 1,
  'values'   => array('','Y','N'),
  'js'      => array(
    'required'    => true,
    'regexp'      => '/^[0-9]*$/',
    'hint'     => 'Please enter a option for Client on Tax'
  ),
  'required' => true,
  'options'  => 'ACV',
  'sort'     => true
);


Is there anything wrong with the above code?

Note: I updated to the latest myphpedit.class.php file

Cheers

Ned

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-09-20 09:14
Back to top  Reply with quote     

is that js loaded with drop down ? (does actual js code appear on html page as it apears with normal text input ? )

if yes, something is wrong with html-js combination (bad variable names,...) i'm not good at this.
if no, core class has to hacked to put js on drop down as well (so a feature request).

 
ned@kelly.org.au     Joined: 08 Apr 2004   Posts: 22   Location: Mosquito Flat, Australia
Post Posted: 2004-09-21 01:00
Back to top  Reply with quote     

Quote:

Is that js loaded with drop down ? (does actual js code appear on html page as it apears with normal text input ? )

No it doesn't

Quote:

if yes, something is wrong with html-js combination (bad variable names,...) i'm not good at this.
if no, core class has to hacked to put js on drop down as well (so a feature request).

will do

thing to note

below is the html source code from the page.

the first value 'telephone_mobile' uses js and works fine as its a normal text entry field and the second value 'client_on_tax' is the drop down list


Code:

   if (phpMyEdit_trim(theForm.telephone_mobile.value) == "" || !(/^[0-9]*$/.test(phpMyEdit_trim(theForm.telephone_mobile.value)))) {
      alert("Please enter a Mobile Telephone number");
      theForm.telephone_mobile.focus();
      return false;
   }

   if (theForm.client_on_tax.selectedIndex == -1) {
      alert("Please enter a option for Client on Tax");
      theForm.client_on_tax.focus();
      return false;
   }




Thanks

Ned

 
sagiben     Joined: 27 Jan 2009   Posts: 15  
Post Posted: 2009-07-25 16:40
Back to top  Reply with quote     

I'm having the same problem,
I still don't know how to solve it but I guess there's a bug in PME because selectedIndex can never be -1 and thus
the 'if' statement will always fail.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy