Page 1 of 1

Can I highlight am Input text from clickng Radio Button?

Posted: Mon Sep 12, 2016 8:35 am
by simonmlewis
I am giving the admin people a choice of using two options, via two radio buttons.
Below the radio buttons are two input fields. One for a Code, one for a URL.

They both use the SAME database field. On the consumer site, it will query if there is a / in the field and if there is, it will provide a URL link.
If there is no / in the field, it will create the URL based on the code.

But in Admin, I want the said field that is selected via the radio buttons, to be "lit", so they now which one they have chosen, will be used. I can do that on page loading, but how do I alter it if they alter the radio buttons. I Assume via some javascript, but not sure how to do it.

Code: Select all

Which link to use: <input type='radio' name='freetext' value='stockcode' checked>stockcode
<input type='radio' name='freetext' value='url'>URL <br/>
Stock Code: <input type='text' name='stockcode' style='width: 160px' value='JHG876'><br/>
Or enter URL: https://www.site.co.uk<input type='text' name='url' style='width: 160px' value='JHG876'>
It's just a means of making sure when they click it, they know full well which one will be used.
It can be lit, or a border added. Not bothered.

Re: Can I highlight am Input text from clickng Radio Button?

Posted: Mon Sep 12, 2016 8:59 am
by requinix
Sounds like there were two different questions in there.

1. How to make it show in Admin? Store the user's choice.
2. How to do something if they pick a different option? Yeah, Javascript. But you'll have to decide how to show the difference. You could highlight or you could use a border or you could show/hide/enable/disable stuff. Pick one and do it.

Re: Can I highlight am Input text from clickng Radio Button?

Posted: Mon Sep 12, 2016 9:02 am
by simonmlewis
In the end, none of them.
I've now decided it's easier to just have admin pop the code or URL in the box, and use a PHP query to see if it is a URL or not (via a query for the /).

But the plan was to click UrL radio button and the urL box would light up yellow.
Same for the stock code box.