[Proto-Scripty] Re: click one checkbox will submit only one checkbox value (not the whole form) immediately
Albert - change the onclick to point to a javascript e.g., input type=checkbox name=choice value=1 onclick=submitjustthisone(); Of course, you will also need to write this function script function submitjustthisone(){ //do the stuff you need to do } /script On Feb 23, 4:58 pm, albert kao albertk...@gmail.com wrote: My JSP web page has many checkboxes. What is web page source code look like when clicking one checkbox will submit only one checkbox value (not the whole form) immediately? i.e. toggling one checkbox will send the info that only that checkbox is toggled. This does not work because clicking one checkbox will send the whole page form name=myform method=post input type=checkbox name=choice value=1 onclick=submit(); input type=checkbox name=choice value=2 onclick=submit(); input type=checkbox name=choice value=3 onclick=submit(); ... -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Change variable value outside onSuccess
In general, it does not strike me as a good idea to have JavaScript tracking whether the user is logged... knowledgeable users could probably get around this fairly easily. In your cfm file redirect them to a login page rather than trying to do it on the javascript side of things. You might want to look at the 'evalScripts' parameter (http:// www.prototypejs.org/api/ajax/updater) and have your cfm file dynamically generate script tags depending on whether or not they are logged in. Al On Jan 6, 2:08 pm, Ian Raphael list...@gmail.com wrote: Hello everybody. I'm starting to use prototype framework and i'm having a problem. I have an ajax javascript function that checks if the user is logged. This function uses coldfusion's native ajax. The code function userLogged(){ var $userLogin = new objUser(); //objUser is a coldfusion component var result = $userLogin.getUserLoginStatus(); //getUserLoginStatus is a method return result; } function checkLogged(){ var logged = userLogged(); if(logged == true) alert('logged'); else alert('not logged'); } But i need to replace this to one written with prototype. I tried the code down (the return of cfm script is a JSON). function userLogged(){ var logged = false; new Ajax.Request('/includes/GetUserLoginStatus.cfm', { method: 'get', onSuccess: function(r) { var response = r.responseText.evalJSON(); var logged = response.STATUS; } }); return logged; } When i call this function the return always false. Obviously because onsuccess create another function and it doesn't change the value of external variable. I'm asking for you guys if there's some way to change the value of variable logged based on the return of the ajax call? Or there's a way inside onSuccess to return the response to the caller function? Thanks for the attention and sorry for my english. Regards, Ian -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Change variable value outside onSuccess
Forgot to mention... evalScripts should help to take care of the synchronous nature of the call On Jan 11, 7:46 pm, Al C al.caug...@gmail.com wrote: In general, it does not strike me as a good idea to have JavaScript tracking whether the user is logged... knowledgeable users could probably get around this fairly easily. In your cfm file redirect them to a login page rather than trying to do it on the javascript side of things. You might want to look at the 'evalScripts' parameter (http://www.prototypejs.org/api/ajax/updater) and have your cfm file dynamically generate script tags depending on whether or not they are logged in. Al On Jan 6, 2:08 pm, Ian Raphael list...@gmail.com wrote: Hello everybody. I'm starting to use prototype framework and i'm having a problem. I have an ajax javascript function that checks if the user is logged. This function uses coldfusion's native ajax. The code function userLogged(){ var $userLogin = new objUser(); //objUser is a coldfusion component var result = $userLogin.getUserLoginStatus(); //getUserLoginStatus is a method return result; } function checkLogged(){ var logged = userLogged(); if(logged == true) alert('logged'); else alert('not logged'); } But i need to replace this to one written with prototype. I tried the code down (the return of cfm script is a JSON). function userLogged(){ var logged = false; new Ajax.Request('/includes/GetUserLoginStatus.cfm', { method: 'get', onSuccess: function(r) { var response = r.responseText.evalJSON(); var logged = response.STATUS; } }); return logged; } When i call this function the return always false. Obviously because onsuccess create another function and it doesn't change the value of external variable. I'm asking for you guys if there's some way to change the value of variable logged based on the return of the ajax call? Or there's a way inside onSuccess to return the response to the caller function? Thanks for the attention and sorry for my english. Regards, Ian -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Collecting checked checkboxes
Take a look at either 1. getInputs()... (http://www.prototypejs.org/api/form/getInputs) or 2 . the $$ construct... http://www.prototypejs.org/api/utility/dollar-dollar If you choose the $$ option, it'll be easier if all of the checkboxes belong to the same class - e.g., class='first_checkbox' You could do something like var checkboxes = $$('first_checkbox'); or var checkboxes = $$('input:[type=checkbox]'); // if they're not all the same class then checkboxes.each( function(s){ //build the query string for your Ajax request }); On Jan 11, 3:11 am, Hussein B hubaghd...@gmail.com wrote: Hey, I have a checkbox in front of each row in my table. Upon clicking on submit button, I want to collect the checked boxes and send values via Ajax request. How to iterate over the checked boxes? Thanks for help and time. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Wow, really new at this
In the sample code above, I suspect that you've given the wrong id the second input field... With that oops mistake corrected, I strongly recommend that (if you've not already done so), get Firefox and install the latest Firebug add- in (and I also recommend the Web Developer toolbar). I've found these to be incredibly useful as I've wrestled with Prototype. Firebug will allow you to observer all of the AJAX HTTP requests in your code. Chrome and IE also have some limited developer tools but IMHO, Firebug is the most comprehensive and is easiest to use. Using Firebug with your form and script above, I get the following request in Firebug's console window: ihttp://localhost/test/product_process.php?product=%5Bobject %20HTMLInputElement%5Dprice=%5Bobject%20HTMLInputElement %5Dwprice=null/i From that it is obvious (ha ha ha) that your Javascript statement: var price = escape($('products_price'+id)); is returning the object rather than the value of the object - i.e. you probably want var price = escape($('products_price'+id).value); or (slightly shorter) var price = escape($F('products_price'+id)); //$F('id) is an abbreviation for $('id').value Of course, prototype gives you many ways to skin the cat... You can add an id attribute to your forms - e.g., form name=product_update117 id=product_update117 action=products.php method=post form name=product_update118 id=product_update118 action=products.php method=post form name=product_update123 id=product_update123 action=products.php method=post etc... and then you can get all of the values in the form into a query string via var pars = $( product_update + id ).serialize( ); However, to make this efficient on the receiving end, you probably want to simplify the id's of the input fields so that they are the same for all form (which will violate all sorts of rules relating to id's supposedly being unique on the page)... its hard to tell how to best handle this without knowing more about the code at the far end. One last recommendation, bookmark the following link: http://www.prototypejs.org/api... (I'd be lost without it ;-) Hope this helps, Al On Jan 3, 7:50 pm, E emiliano.jor...@templatecascade.com wrote: Taking my first tentative steps in JavaScript and I have a stumbling block I can't get past. I'm trying to submit an HTML form using the Ajax.Updater(). I have multiple versions of very similar forms on the same page and would like to seperate them by using a unique ID. My Javascript function is: function submitAJAX(id){ var url = 'product_process.php'; var price = escape($('products_price'+id)); var price_w = escape($('products_price_w'+id)); var pars = 'product=' + price + 'price=' + price + 'wprice=' + price_w; var target = 'output-div' + id; var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars}); } The working part of my form looks something like this. form name=product_update117 action=products.php method=post input type=text name=products_price117 value=25. id=products_price117 input type=text name=products_price_w117 value=12.5000 id=products_price117 /form I can't pull the values from product_update117 using what I am. But I need to somehow have multiple forms for multiple IDs created dynamically. My whole approach might be wrong. Or it just might be my inexperience with JavaScript. But after two days I can't figure it out. I'm in the deep end. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: error showing for prototype.js
If you're using both prototype and scriptaculous, you might want to look at protoaculous... it's a minified single .js file that contains both prototype and scriptaculous. I stumbled across it myself a few weeks ago and easily adding it to my projects (otherwise I am not affiliated with the 'tool' in any way) Latest files are found at http://groups-beta.google.com/group/prototype-core/files Al On Dec 28, 6:59 pm, Tobie Langel tobie.lan...@gmail.com wrote: You're probably having issues because you're including scriptaculous twice (scriptaculous.js's only role is to load files like effects.js and controls.js, so you're effectively including them twice). Let us know if that helps. Tobie -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype Form.serializeElements
How 'bout something like var paramsA = Form.serializeElements( $(frm).getInputs('checkbox', typeA),true); var paramsB = Form.serializeElements( $(frm).getInputs('checkbox', typeB),true); var paramsC = Form.serializeElements( $(frm).getInputs('checkbox', typeC),true); var params = paramsA + '' + paramsB + '' + paramsC; Yeah... I know it's not as sexy as defining the array and running through an 'each' loop but I bet it would work :-) (With string concatenation, you could, of course, do it all in a single variable) Al On Dec 22, 11:27 am, Neede chugalu...@gmail.com wrote: Hello, I've run into a response performance problem with IE6. My form has a 4 scrollable tables that each contain up to 2000 check boxes (names: typeA, typeB, typeC, typeD). serialize() is taking a long time to process, so i was attempting to speed it up by only serializing the check boxes that I need by using: Form.serializeElements( $(frm).getInputs('checkbox', typeA), true); this works fine but i also want to serialize typeB and typeC. I need everything but typeD which happens to have the the greatest number of checkboxes. I tried creating an array for the check box names arChkBoxes = [ typeA, typeB, typeC]; var params = Form.serializeElements( $(frm).getInputs('checkbox', arChkBoxes ), true); Any help on the correct syntax or ideas on how to speed up the serialization is appreciated! -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request
I wrestled with asynchronous calls like you have (and quite honestly, found the structure associated with the onSuccess/onFailure lead to confusing code) I eventually settled on using var myAjax = new Ajax.Updater( target, url, {method: 'post', parameters: pars, evalScripts: true} ); (AFAIK, 'evalScripts: true' does not seem to work with Ajax.Request... someone please corrected me if I'm wrong) I then code within the url to generate the scripts that should be spawned on success or failure (and I can set things so that the scripts don't get called until all of the prerequisite bits are available). Depending on the nature of the calls/results, I occasionally set the target to a hidden div. Once I settled on this approach, I had carefully (re-)structure my code so that calls cascaded properly... i.e., I found that on occasion, the same functions were getting spawned from differenturl's (meaning that the pages could regenerating things unnecessarily). Hope this helps, Al On Dec 20, 6:35 am, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Issues selecting checkboxes in FF
I've got an AJAX page which dynamically refreshes... this is what I use... seems to work well enough for our purposes... (NB - I'm using prototype for most of my stuff) var fin = document.forms[name of form]; // replace name of form with the id of your form var SetCheckBox = function ( w, s0 ){ // 'w' is the id of the checkbox; // 's0' is the state - i.e., 1==checked; 0==not checked fin[ w ].checked = s0; } SetCheckBox( 'item_notchecked', 0 ); SetCheckBox( 'item_checked', 1 ); Hope this helps, Al On Dec 15, 3:18 pm, smartcookie dpell.h...@gmail.com wrote: Hey there: Does anyone know a good way to programmably select or click on a checkbox input in FF? I have tried : el.down('input').checked = 'checked'; and el.down('input').onclick(); In the first code, I can see the checkboxes being checked, but when I submit, my error validation alerts that nothing is selected... Does anyone know another method.. Thanks -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Draggable div only barely visible
I new to script.aculo.us... I added a draggable div to my pages the div is a 'pop-up' dialog... it starts on the page empy and hidden... div id='edit_entry' id='edit_entry' style='display:none'/div script type=''text/javascript'' new Draggable('edit_entry', { scroll: window }); /script A separate script dynamically updates the contents of the div and when the user clicks on a button and I make the div visible with $( target ). show() ; // where target is a variable containing the div name Most of the time it works exactly as intended... Occasionally I have noticed that the div does not seem to appear... but when you look more closely, it is there but only barely visible... it has the wrong opacity... I think. But I'm not doing anything with the opacity Any clues? TIA Al --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---