Click here to Skip to main content
15,887,812 members
Home / Discussions / Java
   

Java

 
QuestionDeveloping a Robust and Secure Online Payment System in Java EE Pin
teknKAL28-May-13 1:03
teknKAL28-May-13 1:03 
AnswerRe: Developing a Robust and Secure Online Payment System in Java EE Pin
Richard MacCutchan28-May-13 2:33
mveRichard MacCutchan28-May-13 2:33 
Questionabout jsp Pin
Swamy Kandi27-May-13 23:16
Swamy Kandi27-May-13 23:16 
AnswerRe: about jsp Pin
Richard MacCutchan28-May-13 0:21
mveRichard MacCutchan28-May-13 0:21 
AnswerRe: about jsp Pin
Prasad Khandekar29-May-13 4:35
professionalPrasad Khandekar29-May-13 4:35 
GeneralRe: about jsp Pin
Swamy Kandi29-May-13 18:37
Swamy Kandi29-May-13 18:37 
Generalabout jsp Pin
Swamy Kandi31-May-13 20:54
Swamy Kandi31-May-13 20:54 
GeneralRe: about jsp Pin
Prasad Khandekar2-Jun-13 8:17
professionalPrasad Khandekar2-Jun-13 8:17 
Hello,

A very simple to do this on client side as opposed to server side, is to output all the required data in form of javascript. Since you are talking about javascript the obvious choice is to output it as a JSON. PLease find below a sample JSON and the code to use it to populate the listboxes.
HTML
<html>
<head>
<title>List Demo</title>
<script type="text/javascript">
var lstData = {
    "key1" : {,
         "value":"value1",
         "sublist": [
             {
                 "key": "key1_1",
                 "value":"value1_1",
             },
             ...
         ]
    },
    ...
};

function fillList1() {
    var ctrl = document.getElementById('list1');
    ctrl.options.length = 0;
    for (var key : lstData) {
        var data = lstData[key];
        var opt = document.createElement('option');
        opt.value = key;
        opt.text = data.value;
        ctrl.options.add(opt);
    }
}

function fillList2(lstOne) {
    if (lstOne.selectedIndex < 1) return;
    var data = lstData[ctrl.value];    // Retrieve the data for selected item in list1
    var ctrl = document.getElementById('list2');
    ctrl.options.length = 0;    // Clear the combox
    for (var key : data.sublist) {
        var subitem = data.sublist[key];
        var opt = document.createElement('option');
        opt.value = subitem.key;
        opt.text = subitem.value;
        ctrl.options.add(opt);
    }
}
</script>
</head>
<body onload="fillList1();">
    <form name="frmMain" id="frmMain" method="post">
        <label for="list1">List 1 : </labl>
        <select name="list1" id="list1" size="1" onchange="fillList1(this);">
            <option value="">Select</option><br/>
        </select>
        <label for="list2">List 2 : </labl>
        <select name="list2" id="list2" size="1">
            <option value="">Select</option><br/>
        </select>
    </form>
</body>
</html>

Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.

Questionhow to create timetable schedule using Genetic Algorithm Pin
mwashahi22-May-13 4:40
mwashahi22-May-13 4:40 
AnswerRe: how to create timetable schedule using Genetic Algorithm Pin
gongxufan@china.java22-May-13 20:31
gongxufan@china.java22-May-13 20:31 
GeneralRe: how to create timetable schedule using Genetic Algorithm Pin
mwashahi22-May-13 20:33
mwashahi22-May-13 20:33 
SuggestionRe: how to create timetable schedule using Genetic Algorithm Pin
Richard MacCutchan22-May-13 21:08
mveRichard MacCutchan22-May-13 21:08 
AnswerRe: how to create timetable schedule using Genetic Algorithm Pin
dusty_dex22-May-13 21:37
dusty_dex22-May-13 21:37 
GeneralRe: how to create timetable schedule using Genetic Algorithm Pin
mwashahi24-May-13 22:34
mwashahi24-May-13 22:34 
GeneralRe: how to create timetable schedule using Genetic Algorithm Pin
mwashahi24-May-13 23:30
mwashahi24-May-13 23:30 
QuestionServer Socket is closed on client closed Pin
Sachin k Rajput 20-May-13 22:47
Sachin k Rajput 20-May-13 22:47 
AnswerRe: Server Socket is closed on client closed Pin
Richard MacCutchan20-May-13 22:57
mveRichard MacCutchan20-May-13 22:57 
GeneralRe: Server Socket is closed on client closed Pin
Sachin k Rajput 20-May-13 23:02
Sachin k Rajput 20-May-13 23:02 
GeneralRe: Server Socket is closed on client closed Pin
Richard MacCutchan21-May-13 2:34
mveRichard MacCutchan21-May-13 2:34 
GeneralRe: Server Socket is closed on client closed Pin
MarlBermudoNights3-Jul-13 22:37
professionalMarlBermudoNights3-Jul-13 22:37 
AnswerRe: Server Socket is closed on client closed Pin
jschell21-May-13 7:57
jschell21-May-13 7:57 
GeneralRe: Server Socket is closed on client closed Pin
Sachin k Rajput 21-May-13 17:29
Sachin k Rajput 21-May-13 17:29 
GeneralRe: Server Socket is closed on client closed Pin
Richard MacCutchan21-May-13 21:15
mveRichard MacCutchan21-May-13 21:15 
AnswerRe: Server Socket is closed on client closed Pin
gongxufan@china.java22-May-13 1:30
gongxufan@china.java22-May-13 1:30 
GeneralRe: Server Socket is closed on client closed Pin
Sachin k Rajput 22-May-13 2:10
Sachin k Rajput 22-May-13 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.