php - Clickable images instead of dropdown menu


I have got an array like:

    'impact' => array(
        'name' => 'Impact',
        'import' => '',
        'css' => "font-family: Impact, Charcoal, sans-serif;",
        'image' => 'impact.png'         
    'palatino-linotype' => array(
        'name' => 'Palatino Linotype',
        'import' => '',
        'css' => "font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;",
        'image' => 'palatino-linotype.png'          

And a dropdown menu like:

        <select name="my-options[primary-font]">
        <?php foreach( $fonts as $font_key => $font ): ?>
            <option <?php selected( $font_key == $current_font ); ?> value="<?php echo $font_key; ?>"><?php echo $font['name']; ?></option>
        <?php endforeach; ?>

I like to use the images from the array instead of the dropdown menu. So when you click an image the font gets selected. Is this possible?




You can have one hidden input field and whenever user clicks the image you set the value of hidden input to the font key with JavaScript.

People are also looking for solutions to the problem: html - How can I get multiple forms to use the same inputs in php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.