简体   繁体   中英

HTML Radio button in body tag, Once selected get all the values for that row and call RPGLE program

I have HTML web page and i am using Table layout to show all the values from database. Now once user select any row using radio button, i want all the values in that row passed on to Iseries/AS400 program. Webpage image How to get all the values from row.. please advise... is there any method of passing those values. In Iseries i am using CGI libraries. In html i am using POST method which i calling backend program.

if each record is a html table row and each cell html table cell, all embedded inside a true html table element, then do the following javascript at the very bottom of the html document just above the end tag:

<table id="tableRecords">
    <tr>
        <td>...cell 1</td>
        <td>...cell 2</td>
        <td>...cell 3</td>
        <td>...etc...</td>
    </tr>
</table>


<script type="text/javascript">

    // assume each radio has a unique id and all radios have the same "class=myRadio"
    let table = document.getElementById("tableRecords");
    let radioButtons = table.querySelectorAll("myRadio");
    let values = []; // we'll capture each cell's values into this empty array
    for(let i=0; i < radioButtons.length; i++){
        radioButtons[i].addEventListener("click", function() {
            let tableRow = this.parentNode;// each radioButton's parent Row
            
            function(tableRow){
                [].slice.call(tableRow.children).forEach(child => {// child is each <td> which we get values from
                    values.push(child.textContent);
                });
            };
        })
    };
</script>

Yes, that's a very basic requirement.

You don't mention which CGI library you are using, but of of them should have documentation, examples and possibly tutorials that will show you what needs to be done to accomplish your request.

Edit
Check out the http://cgidev2.easy400.net/ site...

But basically, you'll probably want to wrap your other RPG program with a CGI RPG program that can convert the query parms or post data into the parameter's needed by the program you want called. Then it's simply a matter of redirecting the user to the new CGI program.

However
Judging from your screen shot, you've got basically a WRKSPLF screen with View , Download and Delete button's I assume you are trying to get to function...

Delete is easy, as there's no real UI for it..

View & Download are a whole other story... you can't simply "call another program" and expect the user to be able to view or download the spool data. Well you could, assuming you've built a program that will convert a spool file to HTML/TXT/PDF that a browser can display or download.

Such a program would normally store the converted stream file in the IFS; in which case it's a simple matter of calling the DspStmf() or DnlStmf() subprocedure included in CGIDEV2.

Honestly CGIDEV2 was a good option 15 years ago, but you'll have to handle a lot yourself. There's much better options now-a-days.

I suggest taking a look at the Tools and Solutions for Modernizing Your IBM i Applications Redpaper by IBM. It's a good start for some of the possibilities. However, even though it was updated in 2017, it doesn't go into some of the opensource options such as PHP, Python or node.js all of which are supported on today's IBM i and offer lot's of possibilities for new development.

Since stackoverflow isn't the place for asking for tool recommendations, consider joining the Midrange.com WEB400 mailing list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM