Count radio buttons
I have two jstl pages, the first one is normal html where i have 5 sets of radio buttons -
a.) <input type="radio" value="john" checked name="R1">
b.) <input type="radio" value="steve checked name="R1">
c.) <input type="radio" value="daniel" checked name="R1">
a.) <input type="radio" value="23" checked name="R2">
b.) <input type="radio" value="34" checked name="R2">
c.) <input type="radio" value="44" checked name="R2">
a.) <input type="radio" value="x2" checked name="R3">
b.) <input type="radio" value="y4" checked name="R3">
c.) <input type="radio" value="u8" checked name="R3">
What i need to do is count how many a's, b's and c's the user have selected - like 2 a's and one c, or 1 b and 2 c's.
how, using jsp or jstl or in a bean can i do this?
I suggest you to do this with javascript.
var el = document.getElementsByTagName('input');
var selected = new Array();
for (var i=0;i<el.length;i++) {
if (el.type == 'radio' && el[i].checked == true) {
selected[el[i].name] = selected[el[i].name] + 1;
There you'll have array with count of the selected radios mapped by the name of the group.
Similar Messages
-
I am creating an interactive form that will be completed by the user online and then printed by that user only. The form is a list of questions with yes/no answers. I have used grouped radio buttons for the yes/no answers. What I now need to do is add a field that will count all yes buttons that have been selected and provide a total. The users will then compare the total value to a legend, no other programming or functionality is required.
I am just a tech writer and have little coding experience. Is there a simple way to do this using FormCalc or does someone have a simple Javascript that would accomplish this?Assuming you have a set number of questions (yes/no radio groups), you can access each of them as follows:
Q1Answer = subformname.Question1.rawValue;
Q2Answer = subformname.Question2.rawValue;
etc.. Question1, Question2 being the names of your radio button groups.
Now if you've got them set as 1 being yes and 0 being no, you just have to add together each of those answers. for example:
TotalYes = Q1Answer + Q2Answer + Q3Answer + ...... -
Counting number of Yes, No or NA Radio Buttons
I have a PDF form with 20 radio button groups with Values of "Yes", "No" and "NA". I need a script to count the number of each value selected by the user.
You need to create a custom JavaScript calculation and test each field's value and count the ones that meet your criteria.
// create a variable to count "Yes" values
var nYes = 0;
// create a variable to count "No" values
var nNo = 0;
// create a variable to count "NA" values
var nNA = 0;
// create a variable to count "Off" values - unselected items
var nOff = 0;
// get the field value for Check Box1
var cValue = this.getField("Check Box1").value;
// test the value and count as needed
if(cValue == "Yes") nYes++; // increment counter
if(cValue == "No") nNo++; // increment counter
if(cValue == "NA") nNA++; // increment counter
if(cValue == "Off") nOff++; // increment counter
// get the field value for Check Box2
cValue = this.getField("Check Box2").value;
// test the value and count as needed
if(cValue == "Yes") nYes++; // increment counter
if(cValue == "No") nNo++; // increment counter
if(cValue == "NA") nNA++; // increment counter
if(cValue == "Off") nOff++; // increment counter
// report results
var cMsg = "Yes answers: " + nYes + "\n";
cMsg = cMsg + "No answers: " + nNo + "\n";
cMsg = cMstg+ "NA answers: " + nNA + "\n";
cMsg = cMstg+ Offo answers: " + nOff + "\n";
You could simplify this by using a loop to process each field. -
RADIO BUTTON TALLY -Auto count & display ticked/selected radio buttons
Hi, feels like this should be simple & straight forward, but obviously for me.
I have a Questionnaire with say twenty YES or NO answers.
I've used grouped Radio Buttons as fields so as to pick one or the other.
I have a read only "YES Tally" text field at bottom of questionaire, formated as 'Number'.
I want the form to automatically calculate & display the number of YES answers (radio buttons) selected or ticked.
How can i achieve this?
ZB.If you have your export value for the buttons set to "1" then you only need to use the calculation option "the field is the sum of: " calculation option., or you can use the 'simplified field notation' to sum the field names. If you use and a different value for the export value,then you need to write a custom script and either test for the export value of the "Yes" button or test for the export value not be "Off".
-
Report should executed based on the radio buttons on the selection screen
Hi everyone,
Greets....................
My scenario is I have 2 selection screen blocks on same screen..
One selection screen block contains input parameters as follows
Company Code - S_BUKRS
Business Area - S_GSBER
Customer Code - S_KUNNR
Fiscal Area - S_GJAHR
GL Account - S_HKONT
Posting Date -S_ZFBDT
Ledger Type -P_RLDNR
Open Item Key Date - P_ZFBDT
Another selection screen block contains 2 radio buttons with the option as follows
Collection Plan
*Credit days summary.
If i click Collection plan the report output should come based on the input parameters in first selection-screen block.
If i click Credit days summary the report output should come based on the input parameters in first selection-screen block.
Pls send me the sample code for this.
Thanks in Advance
Regards
Raj kumarSee the below folling example : it will have radio buttons and depends on radio button it will show output.
REPORT ZPPR_BOM_INFOL_REPORT no standard page heading
line-size 160
line-count 60.
======================================================================
Program Name : ZPPR_BOM_INFOL_REPORT
Description : This Program would be used for BOM List for a material*
and the component's where used list *
Author : Seshu *
Date : 07/24/2006 *
MODIFICATION HISTORY *
DATE | AUTHOR | CHANGE # | DESCRIPTION OF MODIFICATION *
|----
|----
|----
*12/04/06 | Seshu | DEVK921821 | Removed new page for each material *
======================================================================
Table definition *
TABLES: mast,
stko,
stpo,
T418,
makt.
TYPE - POOLS
TYPE-POOLS: slis.
Constants
constants : c_tcode(4) type c value 'CS03',
gc_formname_top_of_page TYPE slis_formname
VALUE 'TOP_OF_PAGE'.
Variables
data : v_maktx like makt-maktx,
wa_stko like stko.
DATA:
Objekttyp 'Material'
otyp_mat(1) TYPE c VALUE '1',
ootyp_mat(1) TYPE c VALUE 'M',
Objekttyp 'kein Objekt'
otyp_noo(1) TYPE c VALUE '2',
Objekttyp 'Dokument'
otyp_doc(1) TYPE c VALUE '3',
Objekttyp 'Klasse'
otyp_kla(1) TYPE c VALUE '4',
Objekttyp 'Intramaterial'
otyp_ntm(1) TYPE c VALUE '5'.
maximal anzeigbare Menge
data: max_num(7) TYPE p DECIMALS 3 VALUE '9999999999.999',
ueberl_kz(1) TYPE c VALUE '*',
min_num(7) TYPE p DECIMALS 3 VALUE '9999999999.999-',
b_flag(1) TYPE c VALUE 'X',
ecfld(250) TYPE c,
v_flag type c.
ALV Variables
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv,
gs_keyinfo TYPE slis_keyinfo_alv,
gt_sp_group TYPE slis_t_sp_group_alv,
gt_events TYPE slis_t_event.
DATA: g_repid LIKE sy-repid.
DATA: gt_list_top_of_page TYPE slis_t_listheader,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_save(1) TYPE c,
gx_variant LIKE disvariant,
g_variant LIKE disvariant,
g_default(1) TYPE c,
g_exit(1) TYPE c.
Includes *
INCLUDE .
Internal Table Declaration *
DATA: t_mast LIKE STANDARD TABLE OF mast WITH HEADER LINE.
*DATA: t_makt LIKE STANDARD TABLE OF makt WITH HEADER LINE.
BOM Function module Related
DATA: t_matcat LIKE cscmat OCCURS 0 WITH HEADER LINE.
Internal Table for Level by Level Function module
DATA: t_stb LIKE stpox OCCURS 0 WITH HEADER LINE.
Get the Relevant data from FM
DATA: BEGIN OF hd_tab OCCURS 0,
stufe LIKE stpox-stufe,
vwegx LIKE stpox-vwegx,
END OF hd_tab.
Final Output
DATA: BEGIN OF alv_stb OCCURS 0.
INCLUDE STRUCTURE stpox_alv.
DATA: info(3) TYPE c,
END OF alv_stb.
DATA: BEGIN OF stb_orig.
INCLUDE STRUCTURE stpox.
DATA: END OF stb_orig.
DATA: BEGIN OF stb_add.
INCLUDE STRUCTURE stpol_add.
DATA: END OF stb_add.
Internal Table for STPO
*-- BOM Line item
TYPES: BEGIN OF ty_stpo,
stlty TYPE stpo-stlty,
stlnr TYPE stpo-stlnr,
stlkn TYPE stpo-stlkn,
stpoz TYPE stpo-stpoz,
idnrk TYPE stpo-idnrk,
meins TYPE stpo-meins,
menge TYPE stpo-menge, "Component Qty
END OF ty_stpo.
DATA: t_stpo TYPE STANDARD TABLE OF ty_stpo WITH HEADER LINE.
*-- BOM Header
TYPES: BEGIN OF ty_stko,
stlty TYPE stko-stlty,
stlnr TYPE stko-stlnr,
stlal TYPE stko-stlal,
stkoz TYPE stko-stkoz,
bmein TYPE stko-bmein,
bmeng TYPE stko-bmeng,
END OF ty_stko.
DATA: t_stko TYPE STANDARD TABLE OF ty_stko WITH HEADER LINE .
data : t_makt like makt occurs 0 with header line.
DATA: BEGIN OF cl_clstab OCCURS 0, "YHG079407
class LIKE klah-class, "YHG079407
klart LIKE klah-klart, "YHG079407
chked LIKE csdata-xfeld, "YHG079407
noobj LIKE csdata-xfeld, "YHG079407
dsply LIKE csdata-xfeld, "YHG079407
END OF cl_clstab.
*-- Header table
TYPES: BEGIN OF ty_main_material,
matnr TYPE mast-matnr, "Material
werks TYPE mast-werks, "Plant
maktx TYPE makt-maktx, "Description
stlal TYPE mast-stlal, "Alternative BOM
stlnr TYPE stko-stlnr, "BOM Number
bmein TYPE stko-bmein, "UOM
bmeng TYPE stko-bmeng, "Base Qty
expand(1) TYPE c, "Expanding Field
END OF ty_main_material.
DATA: t_main_material TYPE STANDARD TABLE OF ty_main_material WITH
HEADER LINE.
*-- Item (Component) Table
TYPES: BEGIN OF ty_item_material,
matnr TYPE mast-matnr, "Material
werks TYPE mast-werks, "Plant
idnrk TYPE stpo-idnrk, "Component (Material)
maktx TYPE makt-maktx, "Description
stlal TYPE mast-stlal, "Alternative BOM
stlnr TYPE stpo-stlnr, "BOM Number
meins TYPE stpo-meins, "UOM
menge TYPE stpo-menge, "Base Qty
END OF ty_item_material.
DATA: t_item_material TYPE STANDARD TABLE OF ty_item_material WITH
HEADER LINE.
Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_werks LIKE marc-werks DEFAULT '1000' OBLIGATORY.
SELECT-OPTIONS s_stlal FOR mast-stlal .
SELECT-OPTIONS s_stlan FOR mast-stlan DEFAULT '1'.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bomlst RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECT-OPTIONS s_matnr FOR mast-matnr.
SELECTION-SCREEN SKIP.
PARAMETERS: p_compon RADIOBUTTON GROUP g1.
SELECT-OPTIONS: s_idnrk FOR stpo-idnrk.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF BLOCK b1.
selection-screen begin of block b03 with frame title text-b03.
selection-screen begin of line.
selection-screen comment 1(40) text-005.
parameters: p_all radiobutton group r1 default 'X'.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(40) text-006.
parameters: p_one radiobutton group r1 .
selection-screen end of line.
selection-screen end of block b03.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b3.
At slection screen events *
*-- Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
Intitialisation
INITIALIZATION.
g_repid = sy-repid.
g_tabname_header = 'T_MAIN_MATERIAL'.
g_tabname_item = 'T_ITEM_MATERIAL'.
*-- define keyinformation
CLEAR gs_keyinfo.
gs_keyinfo-header01 = 'MATNR'.
gs_keyinfo-item01 = 'MATNR'.
PERFORM e03_eventtab_build USING gt_events[].
PERFORM e04_comment_build USING gt_list_top_of_page[].
PERFORM e07_sp_group_build USING gt_sp_group[].
PERFORM e08_layout_build USING gs_layout.
Set Options: save variants userspecific or general
g_save = 'A'.
PERFORM variant_init.
Get default variant
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = gx_variant-variant.
ENDIF.
S T A R T - O F - S E L E C T I O N *******************
start-of-selection.
if p_all = 'X'.
Get the data from MAST and MAKT Table
if p_bomlst = 'X'.
Get the data Based On Material #
perform get_data.
else.
Get the data Based On Component
perform get_data_component.
endif.
else.
Get the Single Level Report
*-- Moved the fiedl catalog here inorder to change the layout based on
*-- Selection
PERFORM e01_fieldcat_init USING gt_fieldcat[].
PERFORM select_data.
endif.
E N D - O F - S E L E C T I O N *******************
end-of-selection.
if p_one = 'X'.
perform alv.
endif.
User Command
at line-selection.
Interactive to CS03 Transaction
case sy-ucomm.
when 'PICK' or 'F2'.
if not alv_stb-idnrk is initial .
if not alv_stb-werks is initial.
if not alv_stb-objty is initial.
SET PARAMETER ID 'MAT' FIELD alv_stb-idnrk.
SET PARAMETER ID 'WRK' FIELD alv_stb-werks.
SET PARAMETER ID 'CSV' FIELD alv_stb-OBJTY.
call transaction c_tcode and skip first screen.
endif.
endif.
endif.
clear alv_stb.
endcase.
*& Form get_data
Get data from MAST and MAKT Table
FORM get_data.
data : wa_lines type sy-index.
REFRESH : T_MAST,
t_STB,
t_MATCAT,
alv_STB.
CLEAR : T_MAST,
t_STB,
t_MATCAT,
alv_STB.
Get the data from MAST Table
Get all the information from MAST - BOM Table
SELECT * FROM mast INTO TABLE t_mast WHERE matnr IN s_matnr AND
werks = p_werks AND
stlan IN s_stlan AND
stlal IN s_stlal.
describe table t_mast lines wa_lines.
if wa_lines is initial.
Write:/2 'List contains no data'.
stop.
endif.
loop at t_mast.
clear : v_maktx.
Start of change Seshu
Reason - Remove the new page option
if sy-tabix ne 1.
skip 1.
endif.
End of Change Seshu
Get the material Description
select single maktx from makt into v_maktx
where matnr = t_mast-matnr
and spras = 'E'.
Get the material details from STKO Table
select single * from stko into wa_stko
where STLTY = 'M'
and STLNR = t_mast-stlnr
and STLAL = t_mast-stlal.
Main Header for Each Material
format color 5 on.
write:/2 'Material',20 'Material Description',65 'Alternative BOM',
90 'Base Qty', 115 'Base Unit'.
format color 5 off.
format color 1 on.
write:/2 t_mast-matnr,20 v_maktx,65 wa_stko-STLAL, 85 wa_stko-BMENG,
115 wa_stko-BMEIN.
format color 1 off.
Use the Function Module and get the format level by level
perform get_level_level.
endloop.
ENDFORM. " get_data
Top of page *
top-of-page.
perform report_header .
*& Form report_header
text
--> p1 text
<-- p2 text
FORM report_header.
new-page line-size 160 .
format color col_heading intensified on.
write:/ sy-uline(160) .
*--- Write Company Name.
perform calc_col_and_write using text-h00
sy-linsz.
*--- Write Report Title.
perform calc_col_and_write using sy-title
sy-linsz.
*--- Write User Id, Date / Time, Program Id, Page etc.
perform write_other_hdr_details.
write:/ sy-uline(160) .
ENDFORM. " report_header
*& Form calc_col_and_write
text
-->P_TEXT_H00 text
-->P_SY_LINSZ text
FORM calc_col_and_write USING P_TEXT
P_LINSZ.
data: col1 type i,
col2 type i,
len type i,
str type i.
str = strlen( p_text ).
col1 = ( p_linsz / 2 ) - ( str / 2 ) .
len = p_linsz - col1 - 2.
write: at /1 '|'.
write: at col1 p_text,
at sy-colno(len) space.
write at 160 '|'.
ENDFORM. " calc_col_and_write
*& Form write_other_hdr_details
text
--> p1 text
<-- p2 text
FORM write_other_hdr_details.
data: col1 type i,
col2 type i,
len type i.
col1 = 3.
write:/1 '|'.
write: at col1 'UserId : ',
sy-uname.
len = sy-linsz - 1.
write at sy-colno(len) space.
col2 = sy-linsz - 18.
write: at col2 'Date: ',
sy-datum mm/dd/yyyy.
write: at sy-linsz '|'.
write:/1 '|'.
write: at col1 'ReportId: ',
sy-repid.
write at sy-colno(len) space.
col2 = sy-linsz - 18.
write: at col2 'Page: ',
sy-pagno.
write: at sy-linsz '|'.
ENDFORM. " write_other_hdr_details
*& Form get_data_component
Get the data based on Component level
FORM get_data_component.
data wa_lines type i.
*-- Get the BOM item details
SELECT stlty stlnr stlkn stpoz idnrk meins menge
FROM stpo
INTO TABLE t_stpo
WHERE idnrk IN s_idnrk.
IF sy-subrc = 0.
CLEAR wa_lines.
DESCRIBE TABLE t_stpo LINES wa_lines.
IF wa_lines > 0.
SELECT stlty stlnr stlal stkoz bmein bmeng
FROM stko
INTO TABLE t_stko
FOR ALL ENTRIES IN t_stpo
WHERE stlnr = t_stpo-stlnr.
CLEAR wa_lines.
DELETE ADJACENT DUPLICATES FROM t_stko COMPARING ALL FIELDS.
DESCRIBE TABLE t_stko LINES wa_lines.
IF wa_lines > 0.
*-- Get the BOM item details
SELECT * FROM mast INTO TABLE t_mast FOR ALL ENTRIES IN t_stko
WHERE werks = p_werks AND
stlnr = t_stko-stlnr
and stlal in s_stlal.
ENDIF.
ENDIF.
else.
Write:/2 'List contains no data'.
stop.
endif.
loop at t_mast.
clear : v_maktx.
Start of change Seshu
Reason - Remove the new page option
if sy-tabix ne 1.
skip 1.
endif.
End of change Seshu
Get the material Description
select single maktx from makt into v_maktx
where matnr = t_mast-matnr
and spras = 'E'.
Get the material details from STKO Table
select single * from stko into wa_stko
where STLTY = 'M'
and STLNR = t_mast-stlnr
and STLAL = t_mast-stlal.
Main Header for Each Material
format color 5 on.
write:/2 'Material',20 'Material Description',65 'Alternative BOM',
90 'Base Qty', 115 'Base Unit'.
format color 5 off.
format color 1 on.
write:/2 t_mast-matnr,20 v_maktx,65 wa_stko-STLAL, 85 wa_stko-BMENG,
115 wa_stko-BMEIN.
format color 1 off.
Use the Function Module and get the format level by level
perform get_level_level.
clear : t_mast.
endloop.
ENDFORM. " get_data_component
*& Form obj_ident
text
FORM obj_ident.
weder Mat noch Doc
CHECK: T_stb-objty NE otyp_mat,
T_stb-objty NE ootyp_mat,
T_stb-objty NE otyp_doc,
T_stb-objty NE otyp_ntm.
?T418-WA schon ok
nein
IF T_stb-postp NE t418-postp.
T418 einlesen
PERFORM t418_lesen USING T_stb-postp.
ENDIF.
PERFORM cl_clstab_maint.
?MatNr-Eingabe bei diesem PosTyp moeglich
und keine Textposition
trifft zu
IF t418-matin NE '-'
AND t418-txpos IS INITIAL.
aktuelles Objekt ist Material NLAG
T_stb-objty = '1'.
PosKurztext in ObjKurztext uebernehmen.
T_stb-ojtxp = T_stb-potx1.
MODIFY T_stb.
ELSE.
IF T_stb-objty IS INITIAL.
T_stb-objty = '2'.
MODIFY T_stb.
ENDIF.
ENDIF.
ENDFORM. " obj_ident
*& Form t418_lesen
text
-->P_T_STB_POSTP text
FORM t418_lesen USING lkl_postp LIKE stpo-postp.
T418-WA initialisieren
CLEAR:
t418.
Key angeben
t418-postp = lkl_postp.
PosTypDefinition lesen
READ TABLE t418.
ENDFORM. " t418_lesen
*& Form cl_clstab_maint
text
FORM cl_clstab_maint.
nur fuer Klassenpositionen
CHECK t_STB-OBJTY EQ OTYP_KLA.
Teilkey der Klassenpositionentabelle
CL_CLSTAB-CLASS = t_STB-CLASS.
CL_CLSTAB-KLART = t_STB-KLART.
Klassenpositionentabelle lesen
READ TABLE CL_CLSTAB
WITH KEY CL_CLSTAB(21)
BINARY SEARCH.
aktuelle Klassenposition bereits in Klassenpositionentabelle
nein
IF SY-SUBRC <> 0.
Klassenposition in Klassenpositionentabelle hinzufuegen
INSERT CL_CLSTAB INDEX SY-TABIX.
ENDIF.
ENDFORM. " cl_clstab_maint
*& Form alv_stb_prep
Printing the data as LEVEL BY LEVEL
FORM alv_stb_prep.
CLEAR:
alv_stb,
stb_orig,
stb_add.
IF t_stb-hdnfo IS INITIAL.
stb_orig = t_stb.
IF t_stb-mngko >= max_num.
stb_add-ovfls = ueberl_kz.
ELSE.
IF t_stb-mngko <= min_num.
stb_add-ovfls = ueberl_kz.
ELSE.
CLEAR: stb_add-ovfls.
ENDIF.
ENDIF.
IF NOT t_stb-xtlnr IS INITIAL.
stb_add-bomfl = b_flag.
ENDIF.
IF NOT t_stb-knobj IS INITIAL
OR NOT t_stb-class IS INITIAL
OR NOT t_stb-kzclb IS INITIAL.
stb_add-knofl = 'X'.
ENDIF.
ELSE.
CHECK t_stb-stufe > 1.
alv_stb-info = 'C30'.
IF t_stb-ttidx <> t_matcat-index.
READ TABLE t_matcat INDEX t_stb-ttidx.
ENDIF.
stb_orig-hdnfo = t_stb-hdnfo.
stb_orig-stufe = t_stb-stufe - 1 .
stb_orig-ojtxp = t_stb-ojtxb.
IF NOT t_stb-altst IS INITIAL.
stb_orig-stlal = t_stb-stlal.
IF stb_orig-stlal(1) EQ '0'.
stb_orig-stlal(1) = ' '.
ENDIF.
ENDIF.
stb_orig-idnrk = t_matcat-matnr.
ENDIF.
CLEAR:
stb_add-dobjt,
stb_add-objic.
CASE t_stb-objty.
WHEN otyp_mat.
WRITE: stb_orig-idnrk TO ecfld.
stb_add-objic = '@A6@'.
WHEN 'M'.
WRITE: stb_orig-idnrk TO ecfld.
stb_add-objic = '@A6@'.
WHEN otyp_noo.
WRITE: stb_orig-potx1 TO ecfld.
stb_add-objic = '@0Q@'.
WHEN otyp_doc.
write stb_orig-doknr to ecfld. "note 489354
IF ecfld CP '*# '. ENDIF. "note 489354
sy-fdpos = sy-fdpos + 1. "note 489354
CONCATENATE
*d stb_orig-doknr "note 489354
stb_orig-dokar
stb_orig-doktl
stb_orig-dokvr
*d INTO ecfld "note 489354
INTO ecfld+sy-fdpos "note 489354
SEPARATED BY space.
stb_add-objic = '@AR@'.
WHEN otyp_kla.
CONCATENATE
stb_orig-class
stb_orig-klart
INTO ecfld
SEPARATED BY space.
stb_add-objic = '@7C@'.
WHEN otyp_ntm.
WRITE: stb_orig-intrm TO ecfld.
WHEN OTHERS.
ENDCASE.
*d CONDENSE ecfld. "note 515408
stb_add-dobjt = ecfld(40).
CLEAR: ecfld.
WRITE stb_orig-stufe TO stb_add-dstuf NO-SIGN.
*d MOVE-CORRESPONDING stb_orig TO alv_stb. "note 331962
MOVE-CORRESPONDING stb_add TO alv_stb.
MOVE-CORRESPONDING stb_orig TO alv_stb. "note 331962
APPEND alv_stb.
ENDFORM. " alv_stb_prep
*& Form get_level_level
text
FORM get_level_level.
REFRESH : T_STB,
T_MATCAT,
ALV_STB.
CLEAR : T_STB,
T_MATCAT,
ALV_STB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01'
datuv = sy-datum
mktls = 'X'
mehrs = 'X'
mtnrv = t_mast-matnr
stlal = '01'
stlan = '1'
stpst = 0
svwvo = 'X'
werks = p_werks
vrsvo = 'X'
TABLES
stb = t_stb
matcat = t_matcat
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: hd_tab.
Entry der KlassenstatusTab. initialisieren
cl_clstab,
Entry 'Objekte von Klassen' initialisieren
cl_objmemo.
REFRESH: hd_tab.
SORT t_matcat BY index ASCENDING.
Get the All levels
loop at t_stb.
IF NOT t_stb-hdnfo IS INITIAL.
EXIT.
ENDIF.
Object Identification
PERFORM obj_ident.
READ TABLE hd_tab
WITH KEY stufe = t_stb-stufe
vwegx = t_stb-vwegx
BINARY SEARCH
TRANSPORTING NO FIELDS.
?gibt es diesen Satz schon
nein
IF sy-subrc <> 0.
dann in SFP-Infosatzverweistab. aufnehmen
*d APPEND HD_TAB. "HGH054648
hd_tab-stufe = t_stb-stufe.
"HGH054648
hd_tab-vwegx = t_stb-vwegx.
"HGH054648
INSERT hd_tab "HGH054648
INTO hd_tab "HGH054648
INDEX sy-tabix. "HGH054648
PosNr initialisieren
CLEAR: t_stb-posnr.
SFP-InfosatzKz setzen
t_stb-hdnfo = 'X'.
stb-objty = otyp_mat.
"HGE246532
als SFP-Infosatz in die STB aufnehmen
append t_stb.
ENDIF.
*del ENDIF.
clear t_stb.
endloop.
SORT t_stb ASCENDING BY stufe
index ASCENDING
*del POSNR ASCENDING. "HGC062735
posnr ASCENDING "HGC062735
hdnfo DESCENDING.
LOOP AT t_stb.
T_stb-index = sy-tabix.
MODIFY T_stb.
PERFORM alv_stb_prep.
ENDLOOP.
Displays the Value as Level by Level
loop at ALV_stb.
if sy-tabix = 1.
format color 3 on.
write:/2 'Level',12 'Item',22 'Component',
42 'Material Description',82 'Base Qty',
107 'Base Unit',120 'Assembly Indicator'.
format color 3 on.
endif.
if alv_stb-MEINs is initial.
v_flag = 'X'.
endif.
if v_flag = 'X'.
format color 5 on.
write:/2 ALV_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP.
format color 1 off.
else.
if alv_stb-STUFE = '1'.
format color 1 on.
write:/2 ALV_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs, 120 alv_stb-bomfl .
format color 1 off.
elseif alv_stb-STUFE = '2'.
format color 2 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl.
format color 2 off.
elseif alv_stb-STUFE = '3'.
format color 3 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl .
format color 3 off.
elseif alv_stb-STUFE = '4'.
format color 4 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl .
format color 4 off.
elseif alv_stb-STUFE = '5'.
format color 5 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl .
format color 5 off.
elseif alv_stb-STUFE = '6'.
format color 7 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl.
format color 6 off.
elseif alv_stb-STUFE = '7'.
format color 7 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl .
format color 7 off.
else.
format color 1 on.
write:/2 alv_stb-STUFE,12 alv_stb-posnr,22 alv_stb-idnrk,
42 alv_stb-OJTXP,72 alv_stb-mngko,
107 alv_stb-MEINs,120 alv_stb-bomfl .
format color 1 off.
endif.
endif.
hide: alv_stb.
clear : alv_stb.
clear v_flag.
endloop.
ENDFORM. " get_level_level
*& Form f4_for_variant
text
FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_for_variant
FORM E03_EVENTTAB_BUILD *
--> E03_LT_EVENTS *
FORM e03_eventtab_build USING e03_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = e03_lt_events.
READ TABLE e03_lt_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_top_of_page TO ls_event-form.
APPEND ls_event TO e03_lt_events.
ENDIF.
ENDFORM.
FORM E04_COMMENT_BUILD *
--> E04_LT_TOP_OF_PAGE -
Dynamic radio button fields do not display again after form is saved
Hello,
I have a group of radio button questions within a dynamic form that display additional questions based on the answer.
So for the question "Is there a basement?" if the user indicates yes, there is a basement, additional questions are displayed to gather more information about the basement. If the user indicates no, then those questions do not appear.
Everything works beautifully in the form. However, when the form is saved and then re-opened, the additional questions do not appear in the form. So the structure goes from this:
To this:
The users must toggle the radio buttons to make those questions reappear...and when they do reappear, they have maintained whatever answer the user indicated before saving.
I'm not sure why this is happening...does anyone have any advice?
Thank you,
TheresaHi,
Thanks so much for your response! I am using Designer 8.2.1.
I just played around with more of my form...this seems to happen whenever I am working with a hidden subform that is displayed when the user clicks a button (or selects the appropriate radio button). I have a couple of other places within my form where this occurs.
Here is an example of the script on one of those buttons:
var intNewIndex = form1.construction_type.const_type_repeat.instanceManager.count-1;
form1.construction_type.resolveNode("const_type_repeat[" + intNewIndex + "]").percentage.presence="visible";
const_type_repeat.instanceManager.addInstance(true);
The script on the radio button is:
if (basementyes.rawValue == 4){secondwd.sump.presence ="visible"
secondwd.sumpradio.sumpyes.presence ="visible"
secondwd.sumpradio.sumpno.presence ="visible"
else {secondwd.sump.presence = "hidden"
secondwd.sumpradio.sumpyes.presence = "hidden"
secondwd.sumpradio.sumpno.presence ="hidden"
I am pretty new at this so it might be something obvious...thanks again for your help! -
am BRAND SPANKING NEW to java and I have a site (created by someone else obviously) which shows 2 text boxes dynamically depending on a number that is entered into the "NumAdults" box. So if you enter "2", you get:
age.text box, tripcost.text box, age.text box, tripcost.text box
What I'm trying to do, is add a radio button to the mix. For example, if you entered "2", I want it to show
age.text box, tripcost.text box, member.radio button, age.text box, tripcost.text box, member.radio button.
The code for the text boxes is working fine but the radio buttons won't work! The radio buttons are elements named rbmember1 through rbmember10. The code - (I've tried to add the radio buttons - please don't laugh) so far is as follows: - Please, can anyone see what I'm doing wrong here?
txtNumAdults.Value = pol.Insureds.Count.ToString();
hdnSelectedPlan.Value = pol.Pol.PlanCode;
for(int i=0;i<pol.Insureds.Count;i++)
TextBox txt = FindControl("txtAdultAge"+(i+1).ToString()) as TextBox;
txt.Visible = true;
txt.Text = pol.Insureds.Age.ToString();
txt = FindControl("txtTripCost"+(i+1).ToString()) as TextBox;
txt.Visible = true;
txt.Text = pol.Insureds[i].TripCost.ToString("n");
Radiobutton rb = FindControl("rbMember"+(i+1)) as RadioButton;
rb.Visible = true;Well, it kind of looks like javascript to me.. (I didn't realize there was a difference!. . that's how new I am)
-
Radio buttons that pass a value to a textfield
Hi everybody;
I’m trying to create a “Rating Matrix” for the evaluation of new raw material. On this form I create a group of radio buttons (i.e. Radio1 to Radio5).
Each radio represents a rating value “Poor=1, Fair=3, Average=5, Good=7, Excellent=9” and I would like to capture this rating (1 or 3 or 5, etc) into a Texfield.
I work in solving this issue without success, if any of you have any example that I could look at it, I will really appreciate.
Thanks in advance.Thanks for your fast response! WowWhat I'm trying to do, is being able to pass a value to a TextField depending on the ratio button selected.If I choose one of the ratio buttons of the group "Opacity" (Opacity1, Opacity2, Opacity3, Opacity4 or Opacity5), I like the TextField "Rank" to show the value.If Opacity1 selected, Rank field value = 1.If Opacity2 selected, Rank field value = 3.If Opacity3 selected, Rank field value = 5.If Opacity4 selected, Rank field value = 7.If Opacity5 selected, Rank field value = 9.
You think this can work?
if(Opacity1.value == "On") {Rank.value==1; // value is added to the texfield;}
if(Opacity2.value == "On") {Rank.value==3; // value is added to the texfield;} Else if(Opacity3.value == "On") {Rank.value==5; // value is added to the texfield;}
Sorry not a programmer.I understand the loop, but is not very clear where I need to add this script, on the radio or in the textfield?Thanks.
Date: Thu, 18 Jul 2013 11:48:28 -0700
From: [email protected]
To: [email protected]
Subject: Radio buttons that pass a value to a textfield
Re: Radio buttons that pass a value to a textfield
created by GKaiseril in JavaScript - View the full discussion
Do you want to count the occurrence of each value and report that in a given text field?
Do you understand that when no radio button or check box when not selected has a value of the string "Off".
Assuming that the value for various radio buttons in a group is the value you want to test
// custom calculation script;
// count occurrences of "9" values
var nTest = 9; // value to test for;
var nCount = 0; // count of occurrences;
// loop through the fields;
for(i = 1; i < 6; i++) {
var nValue = this.getField("Radio" + i).value;
// test if field value equals test value;
if(nTest == nValue) {
nCount++; // values equal so increment count;
} // end test of field value
} // end field name loop;
event.value = nCount; // set field value;
// end custom calculation script;
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5518047#5518047
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5518047#5518047
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5518047#5518047. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
Radio button column in the tabular report
Hi everyone,
I have a tabular report. I wanted to have radio button and check box some of the field. Please take a look at my sample application.
http://apex.oracle.com/pls/otn/
Workspace ==> SHYIN
username ==> SHY
password ==> shy
Application ID : 29879 - TabularForm
On page 2, of the detail form, I want to have radio button in Primary Contact column and check box in status column. I would appreciate any suggession. Thanks.
SHYHi Andy,
I surely come back with new question!
Now, I am trying to change the status column to check box. I can see the correct status the check box in the form. But when I tried to add new rows or update anything, I am getting "No data found" error.
here is my query
SELECT
APEX_ITEM.HIDDEN(1, SEQ_ID) || APEX_ITEM.HIDDEN(2, C001) || APEX_ITEM.RADIOGROUP(3, C001, NULL, NULL, 'onclick="javascript:$x(''P2_SELECTED_ID'').value=' || C001 || '"') PRIMARY_CONTACT,
apex_item.text(4,C002) name,
apex_item.text(5,C004) phone,
APEX_ITEM.HIDDEN(6, C006) || apex_item.checkbox(7,C001, null, C005) INACTIVE
from apex_collections
where collection_name = 'C_CONTACT_INFO'
this is the updated Contact_Collection
begin
IF NOT APEX_COLLECTION.COLLECTION_EXISTS('C_CONTACT_INFO') THEN
apex_collection.create_or_truncate_collection(p_collection_name => 'C_CONTACT_INFO');
for y in (select ID,
NAME,
PRIMARY_CONTACT,
PHONE,
decode(STATUS, 'I', ID, null) status,
CUSTOMER_ID
from CONTACTS
where CUSTOMER_ID = :P2_CUSTOMER_ID)
LOOP
apex_collection.add_member(
p_collection_name => 'C_CONTACT_INFO',
p_c001 => y.ID,
p_c002 => y.NAME,
p_c003 => y.PRIMARY_CONTACT,
p_c004 => y.PHONE,
p_c005 => y.STATUS,
p_c006 => y.CUSTOMER_ID);
end loop;
END IF;
end;
here is my updated Update_Collection process
DECLARE
V_C003 CHAR(1);
V_C001 NUMBER;
V_C005 CHAR(1);
BEGIN
FOR X IN 1..APEX_APPLICATION.G_F01.COUNT
LOOP
V_C001 := APEX_APPLICATION.G_F02(X);
IF V_C001 = :P2_SELECTED_ID THEN
--HTP.P('YES');
V_C003 := 'Y';
ELSE
--HTP.P('NO');
V_C003 := 'N';
END IF;
if APEX_APPLICATION.G_F07(X) = APEX_APPLICATION.G_F02(X) THEN
V_C005 := 'I';
ELSE
V_C005 := 'A';
END IF;
APEX_COLLECTION.UPDATE_MEMBER (
P_COLLECTION_NAME => 'C_CONTACT_INFO',
P_SEQ => APEX_APPLICATION.G_F01(X),
P_C001 => APEX_APPLICATION.G_F02(X),
P_C002 => APEX_APPLICATION.G_F04(X),
P_C003 => V_C003,
P_C004 => APEX_APPLICATION.G_F05(X),
P_C005 => V_C005,
P_C006 => APEX_APPLICATION.G_F06(X));
END LOOP;
END;
I did not make any changes to Save_Contacts process.
Thanks
SHY -
Display radio button if number of rows in table equals 1
I'm having issues buy there maybe a simple script out there.
I have a table which can have up to four rows. If the table contains only one row, a radio button can be clicked to change the format/entry of cells within that row. I want to hide this radio button from a user if they have added more than one row to the table, and make it available again if they reduce the row count back to one.
I have everything else working fine (Radio buttons changing format of row, add/removing rows in the table using buttons, row count in first column)
Anybody got any ideas?
Cheers
BobbyPlace the below code..Change the field names as per your form.
if(Table1.Row1.instanceManager.count == 1)
RadioButton.presence = "visible";
else
RadioButton.presence = "hidden";
Thanks
Srini -
ADDING RADIO BUTTONS IN REPORT NEAR MISS (EHSM-NWBC)
Hi Experts,
I am new to this EHSM Enhancements , I have a requirement to add 3 radio buttons in Report Near Miss ( EHSM-NWBC ), I am not understanding this BOPF firm Enhancement .So please provided me the required information .
Thanks & Regards.
Bhushan K.Hi Bhushan,
If you want to add 3 radio buttons, then first of all you have to append one field in EHHSSS_INC_BASIC_INFO_ALL_D structure with Fixed Domain values.
Then you need to enhance EHHSS_INC_REC_NRM_QAF_V3_BSCI component Configuration.
In that Configuration you need to add field with display type Radio Button Group, with column count 3.
Kindly refer the following snap for the same.
Thanks and regards,
Chetan P. Patil -
What is the code to get the Label of radio button item at runtime?
Hi All
I am working on forms 10g(version 10.1.2.0.2 ) with Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 on windows 2000 platform.
My requirement is to dynamically get the label of the radio button item in a radio group.I am able to get the label of the radio group as shown below
Item :Radio group
Label : Gender
IF m_type = 'RADIO GROUP' THEN
m_label:=Get_Item_Property(m_Item ,label);
END IF;
There two Radio buttons inside this radio group which are
item : Radio button
Label : Male
item :Radio button
Label :female
What is the code to get the label of radio button(i.e) male and female ?
How will I get the count of radio buttons in a radio group at runtime?
Regards
MohanBut you have to provide the button name which cannot be get at runtime.
This is a lack of information that the Dev team would correct !
Francois -
I am making an online exam project and I am currently able to show choices for each question in random order. I want to control all currently open exam sessions so that each student gets a different order of choices during the time of the exam -- to avoid cheating.
I am thinking the best way is to retrieve choices radio button list items in order and insert them into a table by session and compare order for each new session asking for the same question.
Is this the best practice?
How do I get each item from the list and its order to be able to insert it into a table?
Thank you,
Alake wrote:
I 'm not much of a math expert but ...
Let's say you have 5 radio choices 0...4, I am going out on a limb here and predicting there
are 120 combinations? (there are 5 choices for the first button, 4 choices for the second, 3 for the third,
2 for the second and 1 for the last?) So I think you could generate a table of permutations
something like this:
http://www.orafaq.com/forum/t/162827/0/
with test_tab as
(select 1 digit, 1 rn from dual union all
select 2 digit, 2 rn from dual union all
select 3 digit, 3 rn from dual union all
select 4 digit, 4 rn from dual union all
select 5 digit, 5 rn from dual
select t1.digit digit1, t2.digit digit2, t3.digit digit3,
t4.digit digit4, t5.digit digit5
from test_tab t1, test_tab t2, test_tab t3,test_tab t4, test_tab t5
where t1.rn != t2.rn
and t1.rn != t3.rn
and t1.rn != t4.rn
and t1.rn != t5.rn
and t2.rn != t3.rn
and t2.rn != t4.rn
and t2.rn != t5.rn
and t3.rn != t4.rn
and t3.rn != t5.rn
and t4.rn != t5.rn
/note: I did not test that.
Ok so you would have at least one permutation table per number of radio buttons.
You would need to randomize the order in the table like assign dbms_random.random() to
a column say TMPSEQ and then order by TMPSEQ and assign rownum to some field (to get a nice simple key for the records) So then you need a package in plsql that retains
what was the last key (permuation) that was used. When it hits the max it would reset to 1.
I think you might actually have to create a different table for each question even if two questions
had the same number of choices because it would be possible
under unfortunate circumstances for the counter to be reset precisely at the beginning of another person's
test. which would totally wreck the effect you were going for :-) Now, I have tried this function:
http://www.orafaq.com/forum/mv/msg/162827/480976/0/#msg_480976
As I have choices from 1 to 4 I got 24 rows. Is there a way to separate those values? I want to bind each choice with a number from 1 to 4 and change their order based on the permutation I selected from the table. I think I need a function that returns character at certain position e.g. chatAt(str,i) so it would be like:
for i 1 to 4 loop
if(charAt(str,i)=1) then
Select chid into first_choice from choices where QID=:page_item and choiceNumber=1;
endif; ....other cases.... end loop
That would be my first choice in any permutation.
Is it best to create one SEQ for each question so each session just gets the next value of that question? How do I create SEQ's from PL SQL?
I also need to lock my SEQ to avoid access from multiple sessions at the same time if I wanted to save that SEQ for future use of displaying choices that were available like they were originally shown. Finally I need to return the list of choices in order to my radio LOV which I still don't know how to do! Probably a join between question table and my ordered choices on equal chid?
Edit: Maybe this way:
select TEXT display_value, CHID return_value
from table(order_choices(:P37_QID_ITEM))
Instead of the one shown in my earlier post?
Edited by: Cruncher on Jan 18, 2011 9:22 AM
Edited by: Cruncher on Jan 18, 2011 9:26 AM -
Insert String array as label content in datagrid row through radio button C# wpf?
I have written some code for inserting label at runtime having its content set to a string array and then insert that label into a datagrid row . All of this will initiate when certain radiobuttons are checked. code is working perfectly fine. But i need
to improve this code as i am learning C#, wpf and datagrid. I know there can be a certain way to improve this code.
This code will be a nightmare when there are 50 radiobuttons.
can it be improve and how it can be? if u can explain that will be very kind of you
Xaml Code:
<Grid>
<RadioButton x:Name="rb_1" Content="RadioButton" HorizontalAlignment="Left" Margin="351,85,0,0" VerticalAlignment="Top" GroupName="1" />
<RadioButton x:Name="rb_2" Content="RadioButton" HorizontalAlignment="Left" Margin="351,105,0,0" VerticalAlignment="Top" GroupName="1"/>
<RadioButton x:Name="rb_3" Content="RadioButton" HorizontalAlignment="Left" Margin="351,120,0,0" VerticalAlignment="Top" GroupName="1" />
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,159,0,0" VerticalAlignment="Top" GroupName="2" />
<RadioButton x:Name="rb_4" Content="RadioButton" HorizontalAlignment="Left" Margin="351,179,0,0" VerticalAlignment="Top" GroupName="2"/>
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,199,0,0" VerticalAlignment="Top" GroupName="2" />
<Button Content="Button" HorizontalAlignment="Left" Margin="713,60,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
<DataGrid x:Name="datagrid_" HorizontalAlignment="Left" Margin="549,85,0,0" VerticalAlignment="Top" Height="253" Width="399" />
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,226,0,0" VerticalAlignment="Top" GroupName="3" />
<RadioButton x:Name="rb_6" Content="RadioButton" HorizontalAlignment="Left" Margin="351,246,0,0" VerticalAlignment="Top" GroupName="3"/>
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,266,0,0" VerticalAlignment="Top" GroupName="3" />
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,298,0,0" VerticalAlignment="Top" GroupName="4" />
<RadioButton x:Name="rb_8" Content="RadioButton" HorizontalAlignment="Left" Margin="351,318,0,0" VerticalAlignment="Top" GroupName="4"/>
<RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,338,0,0" VerticalAlignment="Top" GroupName="4" />
</Grid>
Code Behind:
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
DataTable dt;
DataRow dr;
string[] str = new string[4];
int location = 0;
int count = 0;
private void Window_Loaded(object sender, RoutedEventArgs e)
dt = new DataTable("emp");
DataColumn dc1 = new DataColumn("Factors", typeof(string));
DataColumn dc2 = new DataColumn("Non_Compliant", typeof(string));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
datagrid_.ItemsSource = dt.DefaultView;
private void Button_Click_2(object sender, RoutedEventArgs e)
if (count >= 1)
datagrid_.ItemsSource = dt.DefaultView;
dt.Clear();
str[0] = "Load Path1";
str[1] = "Load Path2";
str[2] = "Load Path3";
str[3] = "Load Path4";
int j = 0;
if (rb_2.IsChecked == true)
j = 0;
int k = 0;
dr = dt.NewRow();
Label label = new Label();
label.Height = 28;
label.Width = 100;
label.HorizontalAlignment = HorizontalAlignment.Center;
label.VerticalAlignment = VerticalAlignment.Center;
label.Content = str[j];
dr[k] = label.Content;
dt.Rows.Add(dr);
datagrid_.ItemsSource = dt.DefaultView;
location += 34;
if (rb_4.IsChecked == true)
j = 1;
int k = 0;
dr = dt.NewRow();
Label label = new Label();
label.Height = 28;
label.Width = 100;
label.HorizontalAlignment = HorizontalAlignment.Center;
label.VerticalAlignment = VerticalAlignment.Center;
label.Content = str[j];
dr[k] = label.Content;
dt.Rows.Add(dr);
datagrid_.ItemsSource = dt.DefaultView;
location += 34;
if (rb_6.IsChecked == true)
j = 2;
int k = 0;
dr = dt.NewRow();
Label label = new Label();
label.Height = 28;
label.Width = 100;
label.HorizontalAlignment = HorizontalAlignment.Center;
label.VerticalAlignment = VerticalAlignment.Center;
label.Content = str[j];
dr[k] = label.Content;
dt.Rows.Add(dr);
datagrid_.ItemsSource = dt.DefaultView;
location += 34;
if (rb_8.IsChecked == true)
j = 3;
int k = 0;
dr = dt.NewRow();
Label label = new Label();
label.Height = 28;
label.Width = 100;
label.HorizontalAlignment = HorizontalAlignment.Center;
label.VerticalAlignment = VerticalAlignment.Center;
label.Content = str[j];
dr[k] = label.Content;
dt.Rows.Add(dr);
datagrid_.ItemsSource = dt.DefaultView;
location += 34;
count++;@Usamakhan1990,
Use usercontrol with label and checkbox is reasonable for a datagrid control if you don't want to have too much code for those radio buttons. So I agree with andy here with that usercontrol.
So is it required that your radiobutton should be outside the datagrid?
Anyway, I think you already know that you can bind data to columns yourself. So please check the following thread:
http://stackoverflow.com/questions/22922533/how-do-i-automagically-bind-a-string-array-to-a-wpf-datagrid
<DataGrid Name="_dataGrid" Grid.Row="0" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Column 1" Binding="{Binding [0]}"/>
<DataGridTextColumn Header="Column 2" Binding="{Binding [1]}"/>
</DataGrid.Columns>
</DataGrid>
Or define the columns from code, in case you have dynamic number of columns, for example :
string[][] array = fs.CSVToStringArray();
for (int i = 0; i < array[0].Length; i++)
var col = new DataGridTextColumn();
col.Header = "Column " + i;
col.Binding = new Binding(string.Format("[{0}]", i));
_dataGrid.Columns.Add(col);
this.ExternalData._dataGrid.ItemsSource = array;
And for Radio button part, please see here:
http://stackoverflow.com/questions/397556/how-to-bind-radiobuttons-to-an-enum
Best regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Textarea when Radio Button Clicked Yes
I'm trying to add a textarea for a gift message if the users
clicks the "Yes" radio button. The characters have to be limited to
150. I'm not a programmer and know very, very, little coldfusion.
The message in the textarea will be stored in a pre-existing DB
column.
Any help with this is greatly appreciated.<input type="radio" name="giftMessage" value="1"
onclick="textAreaShow('inline');" />Yes
<input type="radio" name="giftMessage" value="0"
onclick="textAreaShow('none');" />No
<textarea name="giftMessageText"
id="giftMessageText"></textarea>
<script type="text/javascript">
function textAreaShow(onOff) {
document.getElementById('giftMessageText').style.display =
onoff;
</script>
for the text limit, that's a little tougher. textareas do not
have the builtin maxlength attribute that text inputs have. there
are javascripts you can use that will fire on the onkeyup event of
the textarea counting the characters, but i personally don't care
for those.
i'd suggest on the submit action of the form, check the
textarea.value length using JS and if it exceeds 150 characters,
don't submit the form and alert the user. in addition, DEFINITELY
check on the form's action page using CF to ensure that the length
of the value passed is less than 150 (and if not, handle
appropriately).
Maybe you are looking for
-
I've recently started experiencing a render problem that I've never encountered before. Editing on a dual 2.7ghz G5 at my work, when I capture DVCPRO video through a DeckLink Extreme card using Blackmagic NTSC 29.97Hz as my device control capture set
-
Connecting a mac to a pc - how?
Does anyone know how I can make my pc and mac talk to each other...share folders etc? Is it even possible to share my USB portable hard-drive on my mac so the pc can see it? Any help would be most appreciate it, i'm useless at these types of things!
-
What components are necessary to install?
To install i9AS, it takes 3 GBs, but OC4J is only about 10Megs. Do I need to install all of i9AS to run the portal?
-
Hi guys, I would like to be advised from experts on one career related question. I have 5 + years of Experience as a DEV and Test. I had mostly worked on VB6, .NET 1.1[ asp.net ,C#] for 3 years as DEV and since 2 years i am into Software System tes
-
Wmv and avi Won't play on new iMac
I used to be able to play wmv and avi on my old G4. I can't play either now. Technically an avi file will open and play on Real Player, but as it "plays" is has neither images nor sound. wmv won't play at all. When I try to open them in Quicktime I g