Setting SELECTED in select box
Hello, I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT> Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right? But it doesn't - it doesn't select anything. Can anyone help me? Regards -- ************************ Gitte Wange Jensen System Squid Developer MMManager Aps +45 29 72 79 72 gitte@mmmanager.org ************************
Hi Gitte, bad idea to use "id" for this, you are probably running into a namespace-problem. To check this, just give out the content of "id" with <dtml-var id> id is probably the id of your document or folder. Try to find an other identifier which is not used by zope itself. Regards Tino Wildenhain --On Dienstag, 8. Mai 2001 14:48 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
Hello,
I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right?
But it doesn't - it doesn't select anything.
Can anyone help me?
Regards -- ************************ Gitte Wange Jensen
System Squid Developer MMManager Aps +45 29 72 79 72
gitte@mmmanager.org ************************
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
No no ... It insert the correct id ... I can see that in the html-source ... so that's not the problem. What makes me wonder is that even though there is an id=27 and a fileid=27 it does set this as SELECTED ... why ? Gitte On Tuesday 08 May 2001 15:39, you wrote:
Hi Gitte,
bad idea to use "id" for this, you are probably running into a namespace-problem.
To check this, just give out the content of "id" with <dtml-var id>
id is probably the id of your document or folder. Try to find an other identifier which is not used by zope itself.
Regards Tino Wildenhain
--On Dienstag, 8. Mai 2001 14:48 +0200 Gitte Wange <gitte@mmmanager.org>
wrote:
Hello,
I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right?
But it doesn't - it doesn't select anything.
Can anyone help me?
Regards -- ************************ Gitte Wange Jensen
System Squid Developer MMManager Aps +45 29 72 79 72
gitte@mmmanager.org ************************
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Have you tried checking to see if one of your 27's is a string and one is a number? I seem to remember that I had this problem before, if I find it I will let you know BTW - you could make the Selected a little snazzier by doing the following.... saves on a few if statements SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <OPTION VALUE="<dtml-var id>" <dtml-if expr="fileid == id">SELECTED></dtml-if>> <dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT> HTH Laurie On Tuesday 08 May 2001 08:45, Gitte Wange wrote:
No no ... It insert the correct id ... I can see that in the html-source ... so that's not the problem.
What makes me wonder is that even though there is an id=27 and a fileid=27 it does set this as SELECTED ... why ?
Gitte
On Tuesday 08 May 2001 15:39, you wrote:
Hi Gitte,
bad idea to use "id" for this, you are probably running into a namespace-problem.
To check this, just give out the content of "id" with <dtml-var id>
id is probably the id of your document or folder. Try to find an other identifier which is not used by zope itself.
Regards Tino Wildenhain
--On Dienstag, 8. Mai 2001 14:48 +0200 Gitte Wange <gitte@mmmanager.org>
wrote:
Hello,
I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right?
But it doesn't - it doesn't select anything.
Can anyone help me?
Regards -- ************************ Gitte Wange Jensen
System Squid Developer MMManager Aps +45 29 72 79 72
gitte@mmmanager.org ************************
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- _________________________________________________ National Center for Macromolecular Imaging Baylor College of Medicine Houston, TX _________________________________________________
Well I think you are right - this could be the problem. But then - how do I make the test to see if they are identical ? fileid proparly is a string and id is an int ... can I convert one of them - if so, how? Gitte On Tuesday 08 May 2001 15:59, Laurie Nason wrote:
Have you tried checking to see if one of your 27's is a string and one is a number? I seem to remember that I had this problem before, if I find it I will let you know
BTW - you could make the Selected a little snazzier by doing the following.... saves on a few if statements
SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <OPTION VALUE="<dtml-var id>" <dtml-if expr="fileid == id">SELECTED></dtml-if>> <dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
HTH Laurie
On Tuesday 08 May 2001 08:45, Gitte Wange wrote:
No no ... It insert the correct id ... I can see that in the html-source ... so that's not the problem.
What makes me wonder is that even though there is an id=27 and a fileid=27 it does set this as SELECTED ... why ?
Gitte
On Tuesday 08 May 2001 15:39, you wrote:
Hi Gitte,
bad idea to use "id" for this, you are probably running into a namespace-problem.
To check this, just give out the content of "id" with <dtml-var id>
id is probably the id of your document or folder. Try to find an other identifier which is not used by zope itself.
Regards Tino Wildenhain
--On Dienstag, 8. Mai 2001 14:48 +0200 Gitte Wange <gitte@mmmanager.org>
wrote:
Hello,
I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right?
But it doesn't - it doesn't select anything.
Can anyone help me?
Regards -- ************************ Gitte Wange Jensen
System Squid Developer MMManager Aps +45 29 72 79 72
gitte@mmmanager.org ************************
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Gitte Wange wrote:
Well I think you are right - this could be the problem.
But then - how do I make the test to see if they are identical ? fileid proparly is a string and id is an int ... can I convert one of them - if so, how?
Gitte
On Tuesday 08 May 2001 15:59, Laurie Nason wrote:
Have you tried checking to see if one of your 27's is a string and one is a number? I seem to remember that I had this problem before, if I find it I will let you know
BTW - you could make the Selected a little snazzier by doing the following.... saves on a few if statements
SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <OPTION VALUE="<dtml-var id>" <dtml-if expr="fileid == id">SELECTED></dtml-if>> <dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
You can convert either automatically using marshalling or using _.int(): <select name="fieldid:int" size="1"> ... The above is converted to an int automatically by Zope and appears as an int to your DTML. or <dtml-if expr="id == _.int(REQUEST.fileid)"> Which does the conversion at the time of the comparison. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
On Tuesday 08 May 2001 16:22, Casey Duncan wrote:
Gitte Wange wrote:
Well I think you are right - this could be the problem.
But then - how do I make the test to see if they are identical ? fileid proparly is a string and id is an int ... can I convert one of them - if so, how?
Gitte
On Tuesday 08 May 2001 15:59, Laurie Nason wrote:
Have you tried checking to see if one of your 27's is a string and one is a number? I seem to remember that I had this problem before, if I find it I will let you know
BTW - you could make the Selected a little snazzier by doing the following.... saves on a few if statements
SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <OPTION VALUE="<dtml-var id>" <dtml-if expr="fileid == id">SELECTED></dtml-if>> <dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT>
You can convert either automatically using marshalling or using _.int():
<select name="fieldid:int" size="1"> ...
The above is converted to an int automatically by Zope and appears as an int to your DTML.
or
<dtml-if expr="id == _.int(REQUEST.fileid)">
Which does the conversion at the time of the comparison.
hth,
Thanks !!! It helped - you've just saved my day :-) Gitte
There is a productive way to approach problems like this - where the problem might be an HTML issue or it might be a Zope issue. It's better if you go through this process before asking for help. You will learn more, create less noise on the list, and get more accurate help with fewer back-and-forth questions and answers. 1) Make sure you know the correct HTML syntax and that you understand how the HTML is supposed to work. - Handcode an example of the html and get it to work in the browser. Make it as SIMPLE as possible. Get a good HTML reference, perhaps the HTML Reference Library (search on line for it). 2) Now change your HTML sample so it contains values similar to those you expect to get from Zope. Keep it as SIMPLE as before. Make sure it still works in the browser. 3) Now use Zope to create an HTML page as much like your hand-crafted sample as possible. - Check to see if it works in the browser. - Look at Zope's HTML and see if it matches your example. This should be easy if you have SIMPLIFIED the example. By now, either you have fixed the HTML or you know it's something about Zope or HTML that you don't quite understand, and you know which one is the problem. Now you may be ready to ask for help. When you ask for the help, be concise and specific. Use your simplified example. For instance: "I want to produce THIS HTML. My Zope code is HERE, but it produces THIS RESULT instead. The problem seems to be in the <whatever part>. How can I produce my HTML?" Or "I want to produce this result with HTML. I expected that THIS HTML CODE would work, but it does THIS instead. How should I change my HTML to do what I said I want?" (If it's really an HTML problem, though, this list isn't the place for it) In your case, Gitte, you should make sure that you have a sample of HTML that selects the correct option when the page loads. You don't even need Zope for that. Then make sure that Zope is really giving you the correct values in its output, so that it reproduces the HTML that you know works. If you have already done this, you should say so in your post. Cheers, Tom P [Gitte Wange] I have run into this weird problem: I am trying to set an option in a select box SELECTED in the id of the option is the same as the value of the select box. The code looks like this: <SELECT NAME="fileid" SIZE="1"> <OPTION VALUE="0">-- Select mediafile --</OPTION> <dtml-in sqlGetMediafiles> <dtml-if fileid> <dtml-if expr="fileid == id"> <OPTION VALUE="<dtml-var id>" SELECTED><dtml-var filename></OPTION> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> <dtml-else> <OPTION VALUE="<dtml-var id>"><dtml-var filename></OPTION> </dtml-if> </dtml-in> </SELECT> Now when I have selected a file, I can see that the fileid variable is set. Well then the select box should select the file that has that id right? But it doesn't - it doesn't select anything.
participants (7)
-
Casey Duncan -
Gitte Wange -
Gitte Wange -
Laurie Nason -
marc lindahl -
Thomas B. Passin -
Tino Wildenhain