Jump to content

radio buttons checked..how to


jimfog

Recommended Posts

In my app a business user fill in a form the services he/she offers along with the option if the prices of them are to be visible to the end-user.

And if at sometime he/she wishes to edit these data he/she clicks the edit button...presented to him/her like this fiddle.

You can see what happens when the user clicks the edit button.

And now my problem:

Focus on the price visibility section...when the edit button is clicked the radio button checked must be the one the user has selected from before.If the user has opted for price visibility then the radio button checked must reflect this...(yes in this case).In the JS pane you see code that gathers the values witch reperesent this(in both services this is 1 and this means the user has opted for price visibility in both services).

The problem is that the radio button of only one service is selected...the other ought to be also(the top)...but it does not.We have the value of 1 also for the top service....as such YES must be selected too.

So there must be something wrong with the JS code...specifically with the replace HTML  method.

I tried to be clear,if there is something you do not understand ask me to clarify further.

Link to comment
Share on other sites

13 hours ago, dsonesuk said:

A radio button with same group attribute name value, can only have one selection at a time. checkbox can have multiple, also you have duplicate  identical id reference showing.

Your answer is very general and it does not address my issue....and you say there is identical ID...I see none.

It seems your answer is relevant after all....I found the cause of the problem but for the time being I do not know how to solve it.

Edited by jimfog
Link to comment
Share on other sites

Instead of finding each occurrence of class and replace with another, loop through using .each() and using index of each function (check jquery for example reference), apply this index to value of name attribute so it becomes

name="form0[][price_show]"
name="form0[][price_show]"

name="form1[][price_show]"
name="form1[][price_show]"

for radio button grouping related to specific service

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...