JS Equiv For PHP Foreach()

Feb 14, 2006

Is there a similar function in JS as the PHP foreach() loop?

foreach($something as $key => $value)
{
execute code here;
}

I have created an object in JS:
var ibm = new Object();

ibm[Ɔ'] = 240;
ibm[Ƈ'] = 241;
ibm[ƈ'] = 242;
ibm[Ɖ'] = 243;
etc...

and I want to access it as
if($key == $somthing)
{
$this = $this;
}

View 8 Replies


ADVERTISEMENT

Equiv Of Border=1 In Table

Sep 4, 2006

Wondered if you could let me know if I've missed something when setting up a
table.

If I use the following:

<TABLE WIDTH=500 BORDER=1>
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
</TABLE>

All 4 sides of all of 4 table cells have a border 1 pixel in depth -
perfect!

If I change this to:

<TABLE WIDTH=500 STYLE="border: 1px dashed black">
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
<TR><TD>fred</TD></TR>
</TABLE>

I only get a border on the outer 'wall' of the table - no borders on the
cells!!!

Due to the project I'm working on, I'm dynamically creating rows and cols in
DOM, I'd really like to just specify that all of the cols/rows have a border
in one go like the old table method rather than having to define the border
style for each cell.

I can't use the old table method of BORDER=1 because I need the dashed style
rather than a solid border. Any ideas on how I can do this?

View 3 Replies View Related

W3C Equiv Of Document.selection.clear()

May 9, 2005

According to Google I'm the first person ever to have had this problem. I'm looking for the Gecko equivalent of document.selection.clear() or (better) document.selection.empty().

I'll try to lay out what I'm trying to do. I register an mouseup handler on the document to fire a function to find what text is selected. Code:

View 7 Replies View Related

Foreach() In Javascript?

Jul 20, 2005

How do I create an array in JavaScript and then go through it?

I want to feed a function with the string "foo,bar,rab,oof" and want JavaScript to do something with each line, like this (in pseudo-code):

myfunc("foo,bar,rab,oof");

function myfunc(string){
foreach i (split(",", string)){
alert(i);
}
}

Or something like that.

View 4 Replies View Related

Foreach From Number, Not Array?

May 2, 2011

i can scoured but cannot find a way to simply iterate an amount set by a number. both .each() and for(); seem to require the length of an array.

in php you can say if(startNum; is less than or equal to toNum;plusOne) but that doesn't work the same way. is there any way to iterate through something like this, using the javascripts for loop?:

Code:
var quantity = 20;
for( i=1; i <= quantity; i++){
return "blah blah";
}

View 6 Replies View Related

JQuery :: Combo Box At Run Time-options Generated By Foreach?

Jul 20, 2010

i have added html elements at run time using append

function addFormField()
{
$("#inputss").append("<strong>abc</strong>");

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved