PHP HowTo: return result of dropdown menu to change html class on text/image area?
Permalink Browser Info Environment
Hi there,
Just wondering if anyone could help me with this.
Im creating a block, using designer content and want to have a text area and a dropdown menu that changes the html class on the text area for instance choosing 'top, middle or bottom' on the dropdown menu would then change the html class on the text area.
Also, would this dropdown menu need to appear before the text area so the result was ready before the text area needs it...?
I can imagine there would be many many many other uses for this not just my changing html classes..
Thanks in advance and sorry if this is a n00b question!
Just wondering if anyone could help me with this.
Im creating a block, using designer content and want to have a text area and a dropdown menu that changes the html class on the text area for instance choosing 'top, middle or bottom' on the dropdown menu would then change the html class on the text area.
Also, would this dropdown menu need to appear before the text area so the result was ready before the text area needs it...?
I can imagine there would be many many many other uses for this not just my changing html classes..
Thanks in advance and sorry if this is a n00b question!
Type: | Discussion |
---|---|
Status: | New |
Hey Jordan,
Firstly... Thank you for investing your time into this add-on, its a God-send!
Wow cool, I hadnt thought of having it update on the fly while in in edit.php.. I had a friend suggest using php switch (view.php pasted below) to update the 2 different classes on my text area.
Heres the code so you can see how we made it work..
Im sure there is a much more efficient way to write this file, but this has worked perfectly so far in giving the user the ability to switch between left/right and top/middle/bottom placements of the headlines.
Im going to try your suggestion above also, as Im sure both ways have their uses!
Thanks again Jordan!
Firstly... Thank you for investing your time into this add-on, its a God-send!
Wow cool, I hadnt thought of having it update on the fly while in in edit.php.. I had a friend suggest using php switch (view.php pasted below) to update the 2 different classes on my text area.
Heres the code so you can see how we made it work..
<!-- dropdown menu for left/right placement --> <?php if ($field_3_select_value == 1): ?> <!-- ENTER MARKUP HERE FOR FIELD "Headline Left or Right" : CHOICE "head-left" --> <?php endif; ?> <?php if ($field_3_select_value == 2): ?> <!-- ENTER MARKUP HERE FOR FIELD "Headline Left or Right" : CHOICE "head-right" --> <?php endif; ?> <!-- drop down menu for top / middle / bottom placement --> <?php if ($field_4_select_value == 1): ?> <!-- ENTER MARKUP HERE FOR FIELD "Headline placement" : CHOICE "top" --> <?php endif; ?> <?php if ($field_4_select_value == 2): ?> <!-- ENTER MARKUP HERE FOR FIELD "Headline placement" : CHOICE "middle" --> <?php endif; ?> <?php if ($field_4_select_value == 3): ?>
Viewing 15 lines of 43 lines. View entire code block.
Im sure there is a much more efficient way to write this file, but this has worked perfectly so far in giving the user the ability to switch between left/right and top/middle/bottom placements of the headlines.
Im going to try your suggestion above also, as Im sure both ways have their uses!
Thanks again Jordan!
Note that I'm also assuming the value for the dropdown is the class name itself. If it's not, you'll need to figure out how to convert the dropdown value to the proper class name and pass that to the "addClass" function.
Good luck!
-Jordan