Solved

Implementing HTML page actions without javascript

Posted on 2014-11-26
4
204 Views
Last Modified: 2014-11-27
I have a single HTML page with a form generated by a web server running Python CGI scripts.  I have been asked to have the page change its display to respond to user errors - such as to highlight a field and place an error marker next to it - WITHOUT using Javascript.

Is there any way to do this without having the server CGI scripts receive the user’s responses to the form and craft a redisplay of the page with the HTML rebuilt to show the error marker (with the user’s filled in data)?

Here is the code:
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)

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

Open in new window


-
0
Comment
Question by:camster123
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 40468906
The short answer is no.

Basically there are 2 ways of doing this, the old way and the new way.
The old way is as you need, no javascript, and for that you need to post the whole page, validate everything server-side and if there are errors you need to apply the CSS error classes directly to the rendering HTML elements and push it back to the client.

The "new" way is to post only the data to the server and on error reply with the list of errors and let javascript apply those error css classes to the elements.

So my friend, I'm afraid there's no magic for you :)

Cheers!
0
 

Author Closing Comment

by:camster123
ID: 40468927
Mr. Alexandre Simões2014-11-27 at 05:21:02ID: 40468906
    Please be patient with me
>>The old way is as you need, no javascript, and for that you need to post the whole page, validate everything server-side and if there are >>errors you need to apply the CSS error classes directly to the rendering HTML elements and push it back to the client.

Could you or someone please
     1) Rephrase this expert comment by  Alexandre Simões.
     2) show me a Python function prototypes  for show(.....) and reshow(.....)?
If I am unclear, my English is not that good, please let me know and I will fix it immediately.
Happy Thanksgiving! Cheers!
  frankc123
0
 

Author Comment

by:camster123
ID: 40468929
Mr. Alexandre Simões,
     Please be patient with me
 >>The old way is as you need, no javascript, and for that you need to post the whole page, validate everything server-side and if there are >>errors you need to apply the CSS error classes directly to the rendering HTML elements and push it back to the client.

 Could you or someone please
      1) Rephrase this expert comment by  Alexandre Simões.
      2) show me a Python function prototypes  for show(.....) and reshow(.....)?
 If I am unclear, my English is not that good, please let me know and I will fix it immediately.
 Happy Thanksgiving! Cheers!
   frankc123
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now