This topic needs a title

I am trying to add some php code to the location of the ‘selected’ text would be in each list item, the problem I have is the ‘value=“”’ after each <option, the first addition of code is fine but every list item entry thereafter in the same menu and any other menus on the page has the 'value=“” after the insertion, so the first menu list would be something like:

>my value1 value="my value2">my value2 value="my value3">my value3

and any other like this:

value="my value1">my value1 value="my value2">my value2 value="my value3">my value3

when they should look like:

>my value1 >my value2 >my value3

The code I am using is:

var allMenuOptions = theListTag.fwFindAll(“option”);

for (n in allMenuOptions) {
menuOption = allMenuOptions[n];
if (menuOption.value) {

    var menuValue = menuOption.value;
    var menuValueAsStr = menuOption.value.toString();
    var insertLoc = menuOption.fwAddRaw("",menuValue); // Use menu value... unconverted toString()
    insertLoc.fwAddRaw("<? code here ?>");

    if (menuOption.selected) {
        menuOption.selected.fwDelete();
    }
}

}

I have a workaround where I delete the value parameters and then add them again with the code but this then adds a second space before the value=“”, this is probably not important… I was more interested in wondering why the code above didn’t work.

The workaround code is:

var allMenuOptions = theListTag.fwFindAll(“option”);

for (n in allMenuOptions) {
menuOption = allMenuOptions[n];
if (menuOption.value) {

    var menuValue = menuOption.value;
    var menuValueAsStr = menuOption.value.toString();
    var optSelCode = menuOption.fwAddRaw("",menuValue);

    menuOption.value.fwDelete();
    menuOption.value=menuValue+"<? code here ?>";

    if (menuOption.selected) {
        menuOption.selected.fwDelete();
    }
}

}

Anyone any ideas on why this is or if it is a bug… or maybe me?

Sorry about the way the code is coming out, just can’t get me head around how to insert code properly!

Mike


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Take a look at the PHP Form Action, written by me and Tim Plumb some years back. This does quite a job on a number of different form elements, including the Select.

As to the code, if you indent everything with 4 spaces or more, you will see a nice formatting on your code. If it doesn’t look right in the preview, don’t press send!

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter,

I did actually do that but couldn’t get some of the segments from the
PHP form action code to work, that’s why I went down another path.

Anyway… This morning Freeway crashed, when it was reopened the
action code printed out * without * the extra space! although the
first version of code still didn’t work as expected, one of the
segments I re-implemented from your PHP Form action also worked so I
guess something must have been amiss which the crash and restart
cleared it out.

In your action you remove the option values from the menu lists, I was
trying to avoid doing this by deleting any ‘selected’ and just add
code into the area any ‘selected’ would have been printed but for each
list item. I have the action now working as I want… for this stage.
I am also deleting the values and re-inserting them with the extra
code that I need, so maybe after cleaning up the code it may be more
logical to go down the same path you did in the PHP Form action.

For some reason I was thinking 2 spaces or a tab, I didn’t think I
knew so much French!

Thanks
Mike

On Dec 17, 2007, at 4:16 AM, waltd wrote:

Take a look at the PHP Form Action, written by me and Tim Plumb some
years back. This does quite a job on a number of different form
elements, including the Select.

As to the code, if you indent everything with 4 spaces or more, you
will see a nice formatting on your code. If it doesn’t look right in
the preview, don’t press send!

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Dec 17, 2007, at 6:17 AM, Mike B wrote:

I was
trying to avoid doing this by deleting any ‘selected’ and just add
code into the area any ‘selected’ would have been printed but for each
list item. I have the action now working as I want… for this stage.

Try looping through all of the options in one pass, and set each
one’s selected value to null.

 for(i in listOptions){
     listOptions[i].selected = null;
 }

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Cheers Walter, I will have a look…

Mike

On Dec 17, 2007, at 2:34 PM, Walter Lee Davis wrote:

On Dec 17, 2007, at 6:17 AM, Mike B wrote:

I was
trying to avoid doing this by deleting any ‘selected’ and just add
code into the area any ‘selected’ would have been printed but for
each
list item. I have the action now working as I want… for this stage.

Try looping through all of the options in one pass, and set each
one’s selected value to null.

for(i in listOptions){
    listOptions[i].selected = null;
}

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options