We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3338
    • 1 Posts
    I’m trying to create a ModX document with a form.
    This form contains several fields, mostly input type=text

    Some fields are select fields.

    This isn’t a problem but sometimes the default values are retrieved from my order database.

    With the text fields I’ve did it in the following way:
    $modx->setPlaceholder(‘fieldname’,’value’);

    How can I do the same thing for select fields?

    My idea was to create a snippet like:

    $output=’<select name="Age" id="Age">’."\n";
    $output.=’<option value="-"’;
    $output.=">-</option>\n";
    for($i=0;$i<=100;$i++)
    {
    $output.="<option value=\"$i\"";
    if($leeftijd==$i)
    {
    $output.=" selected=\"selected\"";
    }
    $output.=">$i jaar</option> \n";
    }

    $output.="</select> \n";

    And call this snippet in the form like [! age? &var=`[+age+]` !]

    Does anyone know how I can manage this?

    Thanks in advance