javascript - Select ONCHANGE for SELECT elements



You can get a select's value with something like this:

var e = document.getElementById("dimen");
var myDimen = e.options[e.selectedIndex].value;

After that you have to associate the value with some sizes. Eg. 1 will stand for 100 * 90, 2 will stand for 200*120, etc.

Hope this helps.




When you change the select, the page reload. The form get the select and see the selected value, finaly you print the good picture!

        <meta charset="UTF-8">  
    <body >
        <form name="formulaire" id="formulaire" action="">
            <select name="select" onChange="submit()">
                <option value="0" >Choose size</option>
                <option value="1" >100*200</option>
                <option value="2" >300*600</option>
                <option value="3" >700*1000</option>
                if($_GET['select'] == '1'){
                    echo '<img src="Capture.png" width="100" heigth="200" alt="mon image">';
                }else if($_GET['select'] == '2'){
                    echo '<img src="Capture.png" width="300" heigth="600" alt="mon image">';
                }else if($_GET['select'] == '3'){
                    echo '<img src="Capture.png" width="700" heigth="1000" alt="mon image">';
                    echo '<img src="Capture.png" width="200" heigth="300" alt="mon image">';



People are also looking for solutions to the problem: php - Language Allowing Rapid Development And Refactoring To Best Practices


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.