Avatar of camster123
camster123

asked on 

I am not allowed to use Javascript . I have to change a CGI web firm HTML select control functions after a user choose an option,

I am not allowed to use Javascript . I have to change a CGI web firm HTML select control functions after a user choose an option,
    Here is the source code:

def output_select(name,options,fields):
    print '<td><select id= "%s" name="%s" value = "selectvalue" class="Required" onchange="usgsChanged(this);" >' %      (name,name)
    output_select_options(name,options,fields);
    print '</select></td>'

def output_select_options(name,options,fields,rc=2):
    selected = fields.get(name,'')
    selected = selected.strip()
    if debug:
      print "SELECTED " + selected
    if len(fields) > 0  and 'phase' in fields: # and fields['phase'] == "1":
      goforit = True
    else:
      goforit = False
    for value,text in options:
        if value==selected or text==selected:
          bar = 'selected="selected"'
        else:
          bar = ""
        print '  <option value="%s" %s>%s</option>' % \
              (value,bar,text)
    if rc == 2:
      print '<script type="text/javascript">document.getElementById(\'%s\').innerHTML = "";</script>'% (name)
      url = os.environ["REQUEST_URI"]
      if debug:
        print url
      url = 'https://eecsappsrv.mit.edu/' + url
      if debug:
        print url
      valuestr =  urlparse(url).query
      if goforit and len(valuestr) > 0:
        fields[name] = urllib.unquote(valuestr)
      output_select_options(name,options,fields,1)

Please suggest to me how to replace the javascript with Python and HTML.
Thank you.
      frankc123
Internet / Email SoftwareSystem ProgrammingProgramming Languages-Other

Avatar of undefined
Last Comment
Dave Baldwin

8/22/2022 - Mon