Solved

Implementing HTML page actions without javascript

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create animated movies for web page 18 85
Hide Table in merge 3 31
Html Table looping 4 25
Button function on table is in trouble 3 20
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

856 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