Getting a selected radio buttons label? - radio-button

I have a group of radio buttons and I am getting the selected one out of this group like this:
var selectedRadio= Form.getInputs('my_form','radio','options[22]').find(function(radio) {
return radio.checked;
});
Now there is a label for each of the radio buttons and I want to get the one for this selected radio button. The radio button has id="options_22_2" for example and the label looks like that:
<label id="options_22_2label" for="options_22_2">
labels text
</label>
So what I want is labels text. Any chance to get that label? Maybe using the ids or something? Its ok to use prototype.
Thanks!
Solved: I now get the id of the selected radio and then get the innerHTML of the label using this id.

Related

How to access ScrollRect items and get it selected and clicked?

I am using Myo so my inputs are not the same as keypress and mouse.
I am trying to access items in the scroll UI Panel. Here is a snapshot of my Unity3D hierarchy.
http://imgur.com/f0cIJWl
As you can see, I have
-StoreMenu
-ScrollPanel
-ScrollRect
-ShopItems (list of items)
How can I possibly scroll and highlight the list of item. And on certain input gesture, get it selected ?
I'ved only managed this far:
scrollpanel = GameObject.Find("ScrollPanel");
scrollRect = scrollpanel.GetComponent<ScrollRect>();
scrollRect.GetComponent<ScrollRect>();
scrollRect.verticalNormalizedPosition = 0.5f;
I can get the scrollrect, move to certain position in the scroll but items are not highlighted.
Thanks in advance.
TRY THIS : http://docs.unity3d.com/462/Documentation/ScriptReference/EventSystems.EventSystem.SetSelectedGameObject.html
This can be used to Set the object as selected

Changing input type=text to type=submit with javascript trigger the submit

i'm trying to code form where you can navigate inside with a next button ( who will hide the current fieldset and show the next one ) and a previous one ( who will hide the current fieldset and show the previous one ). Those two input have a onclick function that will change the fieldset className to active from inactive depending on which fieldset we are. I want to change the next button input type when the user reach the final fieldset so he can submit, but it seems that it automatically trigger the submit event, which means when the user get to the final fieldset, he cant fill any input because the form will submit automatically.
So here's the code :
//When the last fieldset show
if (fieldset[4].className == "active") {
var next = document.getElementById('next');
next.onclick='';
next.type="submit";
next.value="Submit";
next.id='submit';
}
Is there something that i should add to stop the submit auto-firing ?
I've tested your code in JSFiddle and it works good. It means there is something that trigger submit. May be you can post whole javascript in that page and then I can check what is the issue.
var next = document.getElementById("next");
//next.type="submit";
next.setAttribute('type', 'submit'); // I prefer using .setAttribute method
next.onclick='';
next.value="Submit";
next.id='submit';
<form>
<input name="q" value="hello">
<input type="text" id="next">
</form>
I think instead of trying to "hack" the existing button and turn it into the submit, you could just have two buttons, one "next" and another one "submit-button" (hidden initially), once the user advances to the final step, you can hide the "next" button and show the "submit-button" button.
It can be something like this:
//When the last fieldset show
if (fieldset[4].className == "active") {
// hide the next button
document.getElementById('next').style.display='none';
// show the submit button
document.getElementById('submit-button').style.display='';
}
And it would be not complex to make these buttons to appear exactly on the same place with css, so the user will not notice the replacement.
There are browsers who do not allow you to change the type for security reasons. So you will often have problems with it. Just switch between two inputs as boris mentioned (or replace it completely). But to answer your question:
You can catch the autosubmit with another on submit event. First on click mark the button with a class or data attribute like "preventSubmit". Within the submit event check if this class or data attribute exists and prevent the submit (f.ex with prevent default()) and remove the class that all wanted submits by users clicks are not stopped.
Why not just add an event to submit the form you are currently on:
if (fieldset[4].className == "active") {
var next = document.getElementById('next');
next.onclick=(function() { document.forms[0].submit(); });
//next.type="submit";
next.value="Submit";
next.className="MySubmit"; // try to style it as a button for better UX
//next.id='submit';
}

Selecting radio button in geb

I have 3 radio button in a form with ID, value, and name.
With Geb CSS selector I have tired all combination to click on of the radio button but no success!!
I have tried testBtn {$("input", ID:"resident", name:"status")} then in spec testBtn.value("My status") where radio button value="My status", but label next radio button is "Status". Any help appreciate.
You probably don't want to use the id in your selector as this would select only one radio. To mark a radio button as selected you set a value on a set of radio buttons with a given name. For your example that would be:
$('input', name: 'status').value('My status')
or if you used content DSL:
static content = {
status { $('input', name: 'status') }
}
status = 'My status'
Please refer to the section on selecting radio buttons in the Book of Geb.

Windows 8 - GridView does not return SelectedItem when a button inside an item is clicked

I am working on a Win8 Metro Application. I am using a GridView. In GridView's ItemTemplate, I have 3 buttons (Button1, Button2, Button3). So, on my screen, if I have 5 GridView Items at a time, then I will see 5x3 = 15 buttons.
The problem is that if any of these buttons is clicked, I am unable to trace parent GridView Item.
Amongst GridView's properties, "SelectedIndex" (or SelectedItem) properties are there. However, its value is set when GridView item is clicked, (not when a button inside GridViewItem is clicked). So, on clicking button, SelectedIndex remains -1.
How can I find out on ButtonClick that who is the parent item of this button?
From reading your replies in comments, it seems like you want to get the reference to the underlying data item rather than the grid item itself. That being the case, do the following in your button click handler...
Void Button_Click(sender, e)
{
var btn = (Button)sender;
var dc = btn.DataContext as MyBoundType; // don't forget to check for null!
var itemId = dc.Id; // assuming your object has an Id field
}
Bind the CommandParameter of the button to the parent item like this:
<Button
Command="{Binding RemoveCommand}"
CommandParameter="{Binding RelativeSource=
{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
/>

flex edit menu operations on multiple textareas

I have a grid in which one column is having itemrenderer as textarea. My application is menu controled. Now I want to perform edit operations on the textarea using menu items.
Like if I select some text from a textarea in the grid, then I select a menu item "Cut" then it should cut the selected text from the textarea. In this manner I would lie to perform all operations.
I am not getting how to get that the operation is to be performed on which textarea?
inside your menu item click handler, try:
var fcs:IFocusManagerComponent = focusManager.getFocus();
if(fcs is TextArea)
{
var txt:String = TextArea(fcs).text;
System.setClipboard(txt);
}