Can I highlight am Input text from clickng Radio Button?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can I highlight am Input text from clickng Radio Button?

Post 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.
Last edited by requinix on Mon Sep 12, 2016 8:56 am, edited 1 time in total.
Reason: syntax=php -> syntax=html
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post 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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply