Jump to content
jimfog

radio buttons checked..how to

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...