English 中文(简体)
Get Dojo Radio Button Value?
原标题:

I have an HTML form using dojo and have the following code for a radio button selection choice:

dojo.require("dijit.form.RadioButton");
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.2/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.2/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>

<body class="claro">
  <input type="radio" dojoType="dijit.form.RadioButton" name="infoUrgent" value="deferrable" id="deferrable">Deferrable
  <input type="radio" dojoType="dijit.form.RadioButton" name="infoUrgent" value="immediate" id="immediate">Immediate
  <br>

I want to get the value for this radio button and pass it to my "backend" script, but NOT onClick or onChange, only after the user presses a Submit button I have on the form. Usually with textboxes, etc. I can get just use dijit.byId( id ).value or .attr( value ) but since the radio buttons both have different id s I can t use this. The docs from dojocampus mention using the name of the radio button... I m having trouble getting this to work though... could I get some help?

Thanks.

最佳回答

You can use dijit.form.Form instead of standard HTML form, and use myForm.attr( value ).infoUrgent to get value of your radiobutton or just myForm.attr( value ) to get whole form value. myForm here is dojo form object (can be found via dijit.byId etc.).

问题回答
require(["dojo/query"], function(djQuery){
        var retreiveSelected = function() {
        return djQuery( input[type=radio][name=infoUrgent]:checked )[0].value;
    };
})




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签