?
Solved

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,

Posted on 2014-11-25
7
Medium Priority
?
119 Views
Last Modified: 2015-08-10
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
0
Comment
Question by:camster123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 40465925
You can not make it act the same with Python and HTML.  Javascript running in the browser can make changes without reloading the page.  When you user a server-side language like Python, PHP, or ASP, the page must be submitted with every change until you are done.
0
 

Author Comment

by:camster123
ID: 40465966
@Dave Baldwin,
          Thank you very much for your expert comment.
           i was wondering if you could share your idea on how to  make the page must be submitted with every change until you are done. Your English is better than mine.
          Thank you .
            @frankc123
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40465989
First, make a list of all the selections and responses.  Then you have to make a series of pages.  You submit the first one and when you respond from the server it contains the data selected on the first page and the data to be selected for the second page.  In PHP, I would keep track of the selections from each page in Session variables so I could respond with the previous data on each page and send the data on the last page.

It can be kind of complicated because on each page you have to check and see if the data was previously posted and include it in the current request.  That is the only way to include previous selections.  Also, each page must be posted to an intermediate page which collects the information and redirects the user to the next appropriate page.  Without the intermediate page that the user never sees, you will have problems when the user click on the back button.
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

by:camster123
ID: 40466723
@Dave Baldwin,
          Thank you very much for your expert comment.
          I believe your expert comment refers to multiple pages.
          My web form has only one page.
          Thank you.
              frankc123
0
 
LVL 8

Expert Comment

by:Jim Riddles
ID: 40466944
frankc123, unfortunately for you, Dave is spot on.  What you are looking for is client-side interaction.  However, you will need to use a client-side language to achieve that functionality.

The only alternative is to use multiple form pages to achieve a similar result.

If you don't mind, can I ask you why you are unable to use JavaScript?  Are your visitors guaranteed to have JavaScript disabled?  Is it an internal company policy?  Whatever the case, the behavior you seek is not available without using a client-side language.
0
 

Author Comment

by:camster123
ID: 40466998
@Jim Riddles,
        Thank you for your help. I apologize for trying to verify that Mr. Dave Baldwin referred to multiple form pages.

>>If you don't mind, can I ask you why you are unable to use JavaScript?
     The reason is exactly as you stated:  "Are your visitors guaranteed to have JavaScript disabled?"
     Thank you again for your expert comment today.
        frankc123
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40467569
I am definitely talking about multiple pages.  If you can't use javascript, then every change must have it's own page that is processed on the server.  It may be only one page with javascript but it won't be if you have to do all that on the server instead.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Zimbra is famous for its platform independency, ability to manage multiple user accounts, easy assimilation with 3rd party applications, social network certification etc. Here, we discuss about how users can move multiple Zimbra user accounts to Exc…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question