Solved

Implementing HTML page actions without javascript

Posted on 2014-11-26
4
207 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
send email part1 9 39
Non-Resizable Pharagraph 2 17
Allow a tab area under the contents 1 24
Link Anchor Not working 9 43
This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

680 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