Solved

Implementing HTML page actions without javascript

Posted on 2014-11-26
4
208 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
[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
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
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.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

734 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