JQuery :: Checkbox Names Aggregate As Array In A Hidden Input Value?
Jan 19, 2010
In a form, I have multiple checkboxes which represent products whose values are the product prices and names are the product names. When a user clicks submit the next page processes it for cart/purchase purposes.
I need to pass the names of each checkbox to the next page as an array, and it seemed the best way to accomplish this would be to have a hidden input which automatically generates that array in the page then gets passed to the next (via POST) so the application can manipulate the data.
My server-side language is PHP on Codeigniter.
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
I have a php page that names checkboxes in a form chkwhatever# and increments the number depending on how many items there will be. In my javascript i want to be able to check to see if any of the checkboxes are checked but I cant use document.name.chkbox+#.checked. Should I create an array with the checkbox names? Not sure how to go about this.
I'm still struggling with creating a properly formatted form. This problem it two-fold. The first part isn't strictly a javascript problem, but I've included it here because it relates to the second part, which is:
1. Given the form below, how should I structure the input names to get an array like that at bottom?
2. The scripts are used to provide running totals and subtotals. They're fun - try them! But how should I modify these scripts so that they can continue to work with the amended naming policy?
For some reason my script only works when I have at lease two checkboxes. To simulate the problem just run it once with two html input checkbox elements
-> check one checkbox and press submit -> it works -> Now remove one input checkbox field and check the remaining checkbox & submit -> Bamm doesn't work...
Below is the JS code I've used in the past (when my checkbox names/IDs are the same throughout) Code: function checkAll(checkname, exby){ for (i = 0; i<checkname.length; i++) checkname[i].checked = exby.checked? true:false; }
i'm using the slider ui and some hidden input fields to store percentage values in it. I'm having no issue with the plugin itself but with the way jquery gets it's html elements, that's why i'm posting here.
On change the sliders change the value of that hidden field so i can submit the form to get the data into the database.
My problem is that i have multiple sliders on one site and because of that multiple hidden input fields.
All have their own name like "percent[17]" or so.
I'm using this code to get the hidden inputs and change their values: $("input[name=percent[17]]").val(ui.value); I'm hundred percent sure it worked but now it's not working anymore. :(
Should it work or is that "query" to find the html element wrong?
Code: var origGrp = ['James','Bill','Jennifer','Bob','Karen'];
replaced with something like this:
PHP Code:
var origGrp = [<? $sql="SELECT c.new_userid, c.fname, c.lname FROM ".$prefix."_club_users cu INNER JOIN ".$prefix."_users u ON cu.new_userid = c.new_userid
I am trying to open a new window (hidden div) when a checkbox is checked. Right now the way i have it is it is opening when the checkbox is clicked instead of checked.
Here is my code in case someone wants to take a look.
Is there a way, in Javascript, to get a list of files in a folder (on a server) that I can dynamically load into an array that I can work with when a page loads?
i was wondering how you would go about displaying an array of names without hard coding them in the .htm file? example: i have a array of names and the way i list them is to hard code each table entry. what i want to do is have the same array of names, but use javascript to display the names without hard coding it. i want to list 9 columns and have it go until the last name is listed.
i have: function initalize() { this.length = initalize.arguments.length; for ( var i = 0; i < this.length; i++ ) this[ i + 1 ] = initalize.arguments[ i ]; } var familynames = new initalize('list of names here');
<script type='text/javascript'> <!-- panelsArray = new Array("form0","form3","form4","form5","blotter"); var blotter = new Array(འ',騦',魒',饼','block',''); var form0 = new Array(餢',ཱི',骹',餑','block',''); var form3 = new Array(鰌',ྀ',馅',飣','block',''); var form4 = new Array(鮵',髧',駨',飶','block',''); var form5 = new Array(Ɔ',Ɔ',魽',饻','block',''); // --> </script>
and I want to parse the first array and then within that loop I want to get the variable name from the 'outer' array and then reference the contents of the array with that name... I was trying to do the following but it doesn't work, I'm obviously missing something about transmogrifying the text "form0" into a variable name...
I am having a strange issue with jQuery where if someone clicks a checkbox, then a hidden div would slideDown using jQuery but for some reason, the intial click on the checkbox works and shows the hidden div but it does NOT work when you click on the checkbox again to hide the div. [URL] On the borrower and lender tabs you'll see checkbox i speak of by the "Mailing address same as Property Address"
I'm trying to use variable variable names using the window[] functionality. It works fine when you literally specify an array's base variable name, but I have a multidimensional array and would like to use window[] to build the name of the specific sub-array I'm looking for, like so:
// here's my multidimensional array myArray = new Array(); myArray['id'] = 'foo'; myArray['sub'] = new Array();
[Code]....
However if temp is the name of a sub-array (e.g. 'myArray[sub]), and not the base array name(i.e. 'myArray'), then window[temp] evaluates to "undefined".
Can the window[] functionality handle this somehow, or do I have to resort to eval() or something else?
I'm trying to use variable variable names using the window[] functionality. It works fine when you literally specify an array's base variable name, but I have a multidimensional array and would like to use window[] to build the name of the specific sub-array I'm looking for, like so:
Code: // here's my multidimensional array myArray = new Array(); myArray['id'] = 'foo'; myArray['sub'] = new Array(); myArray['sub']['id'] = 'bar';
I have an array for of input names. Input1 , input 2 etc. Can I pass the input names in a loop like document.all[input].value="xxxx"
The problem is document.all cannot be used in Safari/firefox, I tried using document.getElementById but my inputs do have any IDs. is there any way of accomplishing thsse.?
I have a problem created by my complete [rookie] status – only second time venturing into jQuery. I created a simple shopping cart using php and the PayPal buttons (1: buy now, 2: add to cart). The php back end does it great, it generates the table and the buttons and everything works just like it’s supposed to; Except, I forgot to add sizes. So I found out what I need to add, and I realize that the way the buttons work, I will have two different text boxes for size. Not very visually appealing, and since I’m not submitting this to the server before it goes to PayPal to pay, I cannot modify it with php the way I normally would. jQuery / javascript are my only hope of making this work. What I want to do:Have a single textbox where [size] is entered by the user.
Copy the value from the [correct] text box to the Value=”” section of the now hidden field in the PayPal form That way, no matter whether they [BUY NOW] or [ADD to CART] the right size is submitted to the PayPal shopping cart. This is the actual PayPal code that I’m trying to change
I got this far, and then decided to find how to insert the "enteredVALUE" into the right place in the input text field (what I called output) and I've not been able to figure out how to stuff it in there.
I have a script in which I can move users from 1 multiple selectboc (#select1) to another (#select2) and works great, but...Now I want to submit all the users which are moved to #select2 without the risk that some of them is not selected/highlighted.I have read around on the net and found out that I have to append a hidden textfield for each user that has been moved, but can't figure where to put this...Here is what I have:
i have a page with lots of checkboxes and hidden fields. When i tick a checkbox i want it to give the hidden filed a value. But give it no value if it is not ticked. For every checkbox i have a hidden field is with it. Both the checkbox and the hidden field send information. I have used some js scripts but they don't seem to work with more than one checkbox.Example:
So when box1 is ticked it then gives price1 a value. But if not ticked then the value remains at 0. I want it to give a value of 699.There will be about 100 checkboxes and hidden fields on the page. Also onclick behaviours do not work because it may still send the information if the checkbox is not checked.So for the next checkbox and hidden field i use box2 and price2.