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');
I have been checking out the calendar plugins and I was hoping I would find one in which I could display listed events during certain dates. For example, I have a web site for a divers club and we have events that happen on certain dates. I would like to have a calendar in which the user could click a certain date and something shows the user what is going on that day.
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
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?
<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 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 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';
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'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?
I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array.Is it possible to do this or is this use of arrays to display the data the wrong approach?
The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work.
Piece of simple javascript that I can't get to behave. It's a basic image/slideshow..... in the <head> section..... <script type="text/javascript"> var image1=new image() image1.src="../Images/WebSite/HomePage/HpLavender.jpg"; var image2=new image() image2.src="../Images/WebSite/HomePage/HpCreams.jpg"; var image3=new image() image3.src="../Images/WebSite/HomePage/HpBathMelts.jpg"; var image4=new image() image4.src="../Images/WebSite/HomePage/HpCandles.jpg"; var image5=new image() image5.src="../Images/WebSite/HomePage/HpMostlyMen.jpg"; </script>
And then in the body: <img src="../Images/WebSite/HomePage/HpLavender.jpg" name="slide" border="0" alt=""> <script type = "text/javascript"> var step=1; function slideit() { if (!document.images) {return} document.images.slide.src=eval("image"+step+".src");
if (step<5) {step++} else {step=1} setTimeout("slideit()",2500); }slideit(); </script>
The coding seems to be tripping up on the line: document.images.slide.src=eval("image"+step+".src"); (I inserted document.write statements before and after this line and only received the 'before' statement).
The image before the javascript kicks in <img src="../Images/WebSite/HomePage/HpLavender.jpg" name="slide" border="0" alt=""> displays fine - and the images listed in the header are correctly named.
No syntax errors - nothing should be getting in the way of this. All I'm trying to do is implement a different an "onclick" call, which calls the function and AJAXes in some values. Here's my code:
I am attempting to provide the user with an estimated price value given their input in 2 form fields.
One is a dropdown and the other is a radio button set. They will output to a text box
I was able to achieve the desired result using integers as the text box options. However, when i replaced them with strings, the calculations no longer work (obviously )
My problem are:
1. Associating integer values with the word items listed in the dropdown. Example: "standard" should have a value of 100, "deluxe" =200 etc...
2. actually getting the calculation to complete using both dropdown and radio button elements. I'm not sure what logic to use to get it to total out. I essentially want the selected plan flat rate cost ($100 for "standard", $200 for "deluxe")to be added to the additional units cost ($50*number of units selected)
Refer to the reference URL for my intended layout and functionality [url]
I have an array with three dimensions. There are 10 elements in each dimension so I've got a 10x10x10 cube. How can I combine all the elements from one dimension into one layer so I can display the whole cube in a 2-D view?
It is a familiar story. It works in Firefox, but not in IE. I want to dynamically populate a select box with an array of values based upon the value selected from another select. The arrays are defined when the page is loaded.
function selArr(whichArr) { var optStr; var cnt = whichArr.length; for (var i=0; i<cnt; i++) { optStr += '<option value="'+whichArr[i].k+' '+whichArr[i].v+'">'+whichArr[i].k+' '+whichArr[i].v+'</option> '} document.getElementById('sel2').innerHTML = optStr;}
I have run into this before where IE ignores any calls to a function from an option value. However, the problem is if I call the function from the select tag: <select name="someArray" onchange="selArr[this.value);">
this.value is treated not as the defined array but as a var value, as if is enclosed by quotes.
I seem to keep chaging my mind about the best way to do this. I am trying to make a gallery that will display images on a page (without a database!) from a folder when a link is cliked. I have used PHP to read the file paths into an array - and this seems to work perfectly. Its output is similar to this:
Decided to start learning JavaScript, started 2 days ago. Anyway, I'm trying to create a simple script spits out a styled result based on a user input. code...
The problem is that nothing is happening when I press the calculation button.
What I would like to happen is to display a div element for each value in the array which displays the entered value from VenCost2, the current Margin %, and the result of VenCost2 * margin%. I want this to display on the same page and underneath the calculation button, preferably not having to reload the page.
I want to create an array for a religious website that will display a different Bible verse for each day of the year. This is how I incremented each day of the year. var myDate=new Date(); myDate.setFullYear(2011,2,4); myDate.setDate(myDate.getDate()+1); How do I make the connection between the array and the new date as it changes?
This is a snippet from the array. var dailyVerseRef=new Array(); dailyVerseRef[0]="Genesis 1:1"; dailyVerseRef[2]="Genesis 1:2"; dailyVerseRef[3]="Genesis 1:3"; dailyVerseRef[4]="Genesis 1:4"; dailyVerseRef[5]="Genesis 1:5"; dailyVerseRef[6]="Genesis 1:6"; dailyVerseRef[7]="Genesis 1:7"; dailyVerseRef[8]="Genesis 1:8"; I used a switch to go through the days of the week, but to go through the days of the year seems more difficult.
I have an array containing 100 different values. How would I randomly pick 25 of them for display? For now I do: for (var i=0; i<markers.length && i<25; i++) {
html += markers[i].name + '<br />'; }
Which of course returns 25 values but always in the same order which is not what I want. PS. My array could also contain only 20 values, in which case I would like the function to display the 20 values randomly sorted.
this code starts by creating foodArray, 2 dimensional array. Body onload calls fillTable, which fills the table with the first 5 elements of foodArray. In the bottom right is next and last buttons to display different pages of elements in the array. It works fine for foodArray, and because theres 5 elements per page, the 3rd page shows results 11, 12, and 13 as it should. The problem happens when you conduct a search.
Enter "o" in the textbox labelled "food" and it searches foodArray in the appropriate column and returns 8 results. The first 5 results display fine. But when you click next, instead of showing the last 3 results, all 3 entries are undefined. I cannot for the life of me figure out what's wrong. Also, i seem to have to declare the foodArray and resultArray and initialize them with empty values in order for the script to work? Aren't JS arrays supposed to be dynamic?