Page 1 of 1

Radio button with the inputselect popup window?

Posted: 27 Dec 2020 03:40
by qwerty
Could anyone please help me figure out how to change the check box to the radio button in the inputselect popup window? Or any other scripting cmd could achieve similar effects with radio buttons? Thanks.

Re: Radio button with the inputselect popup window?

Posted: 27 Dec 2020 04:26
by highend
That's not possible with inputselect()

You could use html() instead but parsing the return string needs a bit of effort

Re: Radio button with the inputselect popup window?

Posted: 27 Dec 2020 04:39
by qwerty
Thank you for your quick reply.
Can you provide some examples? Does it follow php _GET syntax for the form return values?

Re: Radio button with the inputselect popup window?

Posted: 27 Dec 2020 10:02
by highend
Yes it does.

Code: Select all

    $html = <<<>>>
        <html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
        </head>
        <title>Some title</title>
        <body>
            <form method="get" action="xys:">

                <input type="radio" id="a" name="list" value="a">
                <label for="a">A</label><br>
                <input type="radio" id="b" name="list" value="b">
                <label for="b">B</label><br>
                <input type="radio" id="c" name="list" value="c">
                <label for="c">C</label><br>
                <input type="radio" id="d" name="list" value="d">
                <label for="d">D</label><br>

                <input type="submit" name="ok" value="Ok">
                <input type="submit" name="cancel" value="Cancel">
            </form>
        </body>
        </html>
    >>>;

    // Replace html: &nbsp; (Ascii 160) with real spaces as well
    $htmlResult = replace(utf8decode(urldecode(html($html, 400, 565, self("base")))), chr(160), " ");

    // End if "Cancel" was used ("cancel" submits form parameters, "close" does not!)
    if (strpos($htmlResult, "cancel=Cancel") != -1 || $htmlResult == "") {
        status "Form cancelled...", "8B4513", "stop";
        end true;
    }

    $formRadioButton = regexreplace($htmlResult, "(.*list=)(.*?)(&.*)", "$2");
    text "Selected entry: " . $formRadioButton;

Re: Radio button with the inputselect popup window?

Posted: 28 Dec 2020 05:16
by qwerty
Thank you so much! It helps a lot. :tup: :tup: :tup: