Because I cannot post my actual code I have ginned up a simplified example that demonstrates my intent. Lets say I have a simple CGI script that generates HTML with a little javascript inline.
test.cgi

use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); local our $cgi = new CGI(); my @F_NAMES = ("a","b","c"); my @S_NAMES = (); print $cgi->header(); print qq( <script src='https://blah.blah.js'></script> <script type='text/javascript' language='javascript'> var xml; var xmlObject; var param; function do_Work() { var what = document.getElementsByName('FIRST_SELECTION')[0].v +alue; var test = document.getElementsByName('SECOND_SELECTION'); for(i = 0; i < chec.length; i++) { if(chec[i].checked == true) { type=chec[i].value; } } var build = document.getElementsByName('Build_ID')[0].value; alert(what+" "+test); xmlObject = loadXMLHttpObject(); alert(xmlObject); xmlObject.onreadystatechange = function(){ if(xmlObject.readyState == 4) { if(xmlObject.status == 200) { alert(xmlObject.responseText); //Some kind of assignment statement using document +.getElementsByName??? } } } xmlObject.open("POST", "https://blah_blah.blah2.cgi", true); param = "get_stuff&cmdnV="+what; xmlObject.send(param); } </script>); print $cgi->table({-border=>1, -cellpadding=>'1', -cellspacing=>'0', -width=>'100%', -bgcolor=>'whitesmoke'}), $cgi->Tr($cgi->td({-colspan=>3, -align=>'center'}, "<b>First Name(s):</b><br>", $cgi->scrolling_list( -name => 'FIRST_SELECTION', -values => [@F_NAMES], -size => 1, -default => 'none', -onChange=> 'do_Work();')), $cgi->Tr($cgi->td({-colspan=>3, -align=>'center'}, "<b>Second Name(s):</b><br>", $cgi->scrolling_list( -name => 'SECOND_SELECTION', -values => [@S_NAMES], -size => 5, -default => $S_NAMES[0]));

The javascript calls another cgi using some ajax, and according to the alert, returns the proper data.
I would like to assign that returned data to the scrolling_list with the name 'SECOND_SELECTION'; the theory being that for every element in @F_NAMES there is a number of unique entries for @S_NAMES and the user will need to populate the second scrolling_list with @S_NAMES. Is there a way to make such an update using the DOM and the javascript function do_Work()? Perhaps javascript and perl? I can not seem to find an ID for any of the DOM objects.

Thank you Kindly


In reply to How do I fill a PERL scrolling_list with data returned from a javascript ajax call? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.