How to change v-model source in VueJS? - javascript

I have many Radio Button & I'm creating a Price List with VueJS. Every Radio Button has a value that contains a PRICE like 3000. I get the value of Radio Buttons that User has chosen them by v-model & this property get its value from VALUE Attribute. But the problem is that I need to when First Radio Button chooses, I should add the name of Radio Button like UPVC window or something like that in DB, But my VALUE Attribute has price & I should give all Radio Buttons different NAME Attributes & check them individuals to add a name in DB.
So I asked that Can I say v-model in VueJS to use another attribute like data-price & I use VALUE Attribute to detect the name of Radio Button ?
Maybe It is confusing, If need more detail Please tell me ...

Related

Retrieving Preselected value in Struts 2 from Javascript

I am trying to access the value of a radio button which is already preselected in the form from Javascript but facing issue. In the form there are 2 set of radio buttons holding True and False each. Below is a rough diagram.
O T O F
O T O F
Now when the user selects the first radio button to false then second set of radio button is visible. Now the user chooses any values from the second set of radio button and navigates to first set of radio button and choose T. Now when the user clicks on false a javascript is getting called. In that I need to fetch radio button which is preselected already for the second set of radio buttons.
The preselected value I need to get it in Javascript for second set of radio button.
Code:
<s:radio id="id1" name="name1" list =${'T':'True',' F':'False'}>
<s:radio id="id2" name="name2" list =${'T':'True' 'F':'False'}>
I tried using document.getElementById("id2").value; in javascript but it doesn't give me result i.e. the preselection done in radio button for the second set, as Struts creates different id when it transforms to HTML.
How do I get the preselected value in Javascript for 2nd set of radio button ?
Utilising getElementByID() is fine as a method of retrieving the value you're after.
Struts2 shouldn't automatically be generating your HTML-DOM IDs unless you are using struts form tags, if so then their id is determine by form parameters. Else it's probably on your code for the jsp of the view(page).
Would need to see your jsp code to help, but recommend looking at the .jsp for the page to determine what ID you should look for with getElementByID()

display number of option value of select tag with respect to onchange of radio button value

in this scenario,
there are 4 radio button as 1,2,3,4,and we have select tag with option tag.
so requirement is onchange of radio button, number of option value of select tag should be displayed.
ex:if radio 1 is click, then select tag may have 10 values then first five values should be displayed.
if radio 2 is click,then select tag may have two values then all values should be displayed.
I think pic can explain more.
Please suggest, how to proceed
look at example
Figure 11–4 Example Select One Components
http://docs.oracle.com/cd/E19159-01/819-3669/bnase/index.html
our scenario,is between Genere and Language.
wen I click "Fiction" then, drop down should display only fiction related values and vice versa.fiction related values are list of array.

how dynamically i can checked and unchecked radio button on the basis of list of values returned by controller

I am implementing a edit functionality. Initially user has selected a list of radio buttons while create functionality i have stored them in a table as CSV as string. Now in edit functionality i am getting this list as a string of csv but i am facing difficulty to make radio buttons checked which are in string of csv dynamically.
case1
user has selected 4 radio button out of 10 radio buttons. I have passed this list to controller and saved in a table as String of csv.
case 2
In edit function in controller i am getting a string var like this
String radiolist=radio1,radio2,radio3,radio4
Now i am redirecting to a edit jps page where i want only these 4 radio should get checked rest should be unchecked. can any one help to do this?
You can use serializeArray() method:
$(':radio').serializeArray(); // a name attribute must be set on each radio button
If you want to get an array containing the value for each checked radio button, you can use:
var arrValuesRD = $(':radio:checked').map(function(){
return this.value; // default is 'on' if no value attribute is set
}).get();
try like this:
var val=$("input:radio[name='police']:checked").val();
radioValueArray.push(val);
do same for each name group and push.

how do I make my radio button become clear again when I pick a different value?

I'm posting the link where I am having the problem. I'm having issues with the radio buttons.
I have three images and I'm suppose to be able to click on a radio button and the image changes. That part works great. But when I go for another button, the last one I clicked on stays checked. How do I make it uncheck? I only want what is selected to be checked. ty!!!!!
http://www-desi.iro.umontreal.ca/~valiquki/tp3Kim/TP3KimValiquette.html
The radio buttons have to have the same "name" attribute to be a part of the same group.
Make sure that all of the radio buttons are in the same group. See this for how to do so.
Basically, use the name attribute to assign a group name. That way they will be part of a group and the browser will handle selection/deselection. Name is not the name of the radio button, but the name of the group.
You could use 'side-dishes' if you like for all of them.

Selecting all checkboxes and passing it to another page on click of a button

HI,
I have multiple checkboxes in my report. I am using two buttons Select All and Deselect All for selecting all checkboxes and deselecting all checkboxes. But am not able to pass the checked values to another report. Only if I manually select the checkboxes then only those values are getting passed in the report.
Can anyone help me out with this?
I assume your select all and deselect all buttons are using javascript to set or unset all the other checkboxes in the form.
unset checkboxes are not passed on. only the set one. If you need an explicit 0 or 1 to get passed over, you will have to do something like adding extra hidden fields are are sync'ed to the state of the checkboxes, but this will be riddled with problems (eg, no javascript = FAIL).
You can have a bunch of hidden fields to accompany the checkboxes, and set their values when the checkboxes are unchecked.
Alternately, when you need two or more states for a field, use a radio button.

Categories

Resources