473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

select options with PSP template

Can someone give an opinion whether this is a dumb approach?

I want to generate a list of OPTION elements for s SELECT element, but
I can't see any (clean) way to use a template on a list of values
(other than building HTML outside of the template, which is what I'm
trying to avoid). This is what I came up with.

It uses three template files and the .py file. The trick (for lack of a
better word) is to nest a template inside of itself. Looks a little
lispish to me :^)

It might not be a good idea for really long lists, but a SELECT
shouldn't have all that many options anyway.

########## index.py ##########
from mod_python import psp

def test(req):
...
...nested =''
...
...for x in range(10):
.....nested = psp.PSP(req, filename='opt2.tmpl',
......................vars={'val1': nested,
............................'val2': psp.PSP(req, filename='opt.tmpl',
............................................vars={ 'val':x})})
...tmpl = psp.PSP(req, filename='seltest.tmpl')
...tmpl.run(vars = {'options': nested})
...return
######## seltest.tmpl ###########
<html>
<h2>Test of Select</h2>
<select>
<%= options %>
</select>
</html>

######### opt2.tmpl ###########
<%= val1 %>
<%= val2 %>

######### opt.tmpl ############
<option><%= val %></option>

Jul 18 '05 #1
0 1255

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hal Vaughan | last post by:
I have a sample script from a book ("Beginning JavaScript" by Paul Wilton) that removes or adds a choice to a <SELECT> element. The <FORM> is form1 and the <SELECT> is theDay. The example uses...
1
by: HJ Majoue | last post by:
I am having a problem with RichTextBox Control and hope you can help I am working on a VB.Net project that has a RTB control, the user opens a form template. What I want to do is for a user to be...
3
by: Andy | last post by:
Hi, I'm trying to render tabular data in an HTML document using XSL to transform XML data into an HTML table. Some of the tabular data appears as droplists (implemented by the HTML Select and...
3
by: Beholder | last post by:
I hope that someone can help me with the following: Short background explenation: I have a shrfepoint page (newform.aspx) in a item list. On this page is a lookup column that displays a lookup...
3
by: robski | last post by:
Hello there, I am new to this forum and have done my best to look around for a solution to this problem. I am using PHP to generate an HTML Select drop down menu, with 4 options: function...
2
by: Heltende | last post by:
I'm trying to develop a stylesheet that takes a parameter that is used to filter the results. It works great *except* for the fact that I want one of my options to be a "See All", removing any...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
2
by: djnokturnal | last post by:
Hey guys / gals, First time posting and of course I am sure it is something that has been answered 100 times but for some reason I just cant find the answer :) First off here is the structure...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.