Hi Daniel,

Firstly, it's more effecient to create the callback
function on the outside of the PostData() function

var fn = function(e, success) {
        if (!success) alert ('Server Timeout');
}

Secondly, you'll have to loop through all the
checkboxes and then submit their values together:

function GetCheckBoxValues(chk){
        if (!chk.length) {
                if(chk.checked) return chk.value;
        }else {
                var i,ar=[];
                for(i=0;i<chk.length;i++) {
                        if(chk[i].checked) ar[ar.length]=chk[i].value;
                };      
                return ar.join(',');
        }
};

You can see the util/datasource.js file (lines
368-445) for other examples.

And finally here's what the PostData() function would
look like:

function PostData(formName) {
        var elm,f = eval('document.forms.'+formName);
        var data = {}
        for(var i=0;i<=f.elements.length;i++){
                elm = f.elements[i];
                if (elm != null) {
                if (elm.type == 'text') {
                        data[elm.name]=elm.value;
                        alert(elm.name+':'+elm.value+':'+elm.type);
                }
                else if (elm.type == 'radio') {
                        if (elm.checked) {
                                data[elm.name]=elm.value;
                                alert(elm.name+':'+elm.value+':'+elm.type);
                        }
                }
                else if (elm.type == 'checkbox') {
                        var vl = GetCheckBoxValues(elm);
                        if(vl){
                                data[elm.name] = vl;
                                alert(elm.name+':'+vl+':'+elm.type);
                        }
                }
        }
        ioelement.post('/admin/login.asp?action=PostAddUser',
data, fn);
}


--
Raymond Irving

--- Dev <[EMAIL PROTECTED]> wrote:
> Hi folks!
> 
> I have some problem with posting the checkboxes with
> the ioelement.
> Here is my code:
> function PostData(formName) {
> var fn = function(e, success) {
>       if (!success) alert ('Server Timeout');
>       }
>               var elm,f = eval('document.forms.'+formName);
>               var data = {}
>               for(var i=0;i<=f.elements.length;i++){
>               elm = f.elements[i];
>               if (elm != null) {
>               if (elm.type == 'text') {
>                       data[elm.name]=elm.value;
>                       alert(elm.name+':'+elm.value+':'+elm.type);
>               }
>               else if (elm.type == 'radio') {
>                       if (elm.checked) {
>                               data[elm.name]=elm.value;
>                               alert(elm.name+':'+elm.value+':'+elm.type);
>                       }
>               }
>               else if (elm.type == 'checkbox') {
>                       if (elm.checked) {
>                               data[elm.name]=elm.value;
>                               alert(elm.name+':'+elm.value+':'+elm.type);
>                               }
>                       }
>               }
>       }
> 
>
ioelement.post('/admin/login.asp?action=PostAddUser',
> data, fn);
> }
> 
> The problem is when i retreve the checkbox and i
> have multiple selected just the last one gets
> posted.
> 
> IE: 
> checkbox 1: name=kalle value:1 checked
> checkbox 2: name=kalle value:2 checked
> 
> When i fetch kalle by request.form("kalle") i get
> value:2 and not as regular: value:1,2
> 
> Is this a bug or is it something that i need to do
> myself, if thats the case, how can i do this, i am
> not so good at js yet so this is over my head...
> 
> I must aswell state that you all that have developed
> the new release have done a really really good job!
> 
> Best regards
> Daniel Tiru
> 
> 
>
-------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An
> INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10%
> Monthly Commission!
> INetU Dedicated Managed Hosting
> http://www.inetu.net/partner/index.php
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
>
https://lists.sourceforge.net/lists/listinfo/dynapi-help


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://www.mail-archive.com/[EMAIL PROTECTED]/

Reply via email to