Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

fireindy

fireindy Avatar

**
Official Member

114


May 2007
Ok, I made a form on my headers footers page so the staff can submit info. I have an array in my code that will hold the submit data. The problem is, that I dont think that I am trying to access my array correctly when submitting data. I am currently doing:

function SaveVid(){
var name = document.getElementById('vid_name');
var URL = document.getElementById('vid_url');
var descs = document.getElementById('vid_descs');
gfooter = document.getElementsByName('footer').item(0);
gfooter.value = gfooter.value.vids.push(URL,name,descs);
document.forms.item(0).submit(true);
}


I believe .push is a Javascript command after googling :) If not please tell me. I think the problem is :

gfooter.value.vids.push(URL,name,descs);

Can I do that?


Last Edit: May 21, 2007 1:39:54 GMT by fireindy


3:

3: Avatar
...xD

***
Dedicated Member

158


June 2006
i don't think push takes more than one argument. ;/ though, i could be wrong.

have you tried push(URL + name + descs); ?

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
beta said:
i don't think push takes more than one argument. ;/ though, i could be wrong.

have you tried push(URL + name + descs); ?


I've never used push(), but I'd assume it could take more than one parameter. The PHP function, for example, takes the array name as the first parameter, then every parameter after that is a value to add.

However, for your code, I wouldn't use push() at all (if it even exists). I'd use gfooter.value += '[" ' + URL + ' "," ' + name + ' "," ' + descs + ' "],'; (Note: I just put in the spaces to show the breaks between the quotes; also, I'm assuming that you're adding a set of values into the global footer in an admin-editable code.)


Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
You can't access an array in the footer because it's a string there.

Also, push accept as many parameters as you want.

fireindy

fireindy Avatar

**
Official Member

114


May 2007
mithras said:
beta said:
i don't think push takes more than one argument. ;/ though, i could be wrong.

have you tried push(URL + name + descs); ?


I've never used push(), but I'd assume it could take more than one parameter. The PHP function, for example, takes the array name as the first parameter, then every parameter after that is a value to add.

However, for your code, I wouldn't use push() at all (if it even exists). I'd use gfooter.value += '[" ' + URL + ' "," ' + name + ' "," ' + descs + ' "],'; (Note: I just put in the spaces to show the breaks between the quotes; also, I'm assuming that you're adding a set of values into the global footer in an admin-editable code.)


Well I could do that, but Id have to find the array in the string(thanks Chris), first. :) Thanks guys, I have to think about this one :P


Moose

Moose Avatar

****
Senior Member

449


August 2005
fireindy said:
mithras said:


I've never used push(), but I'd assume it could take more than one parameter. The PHP function, for example, takes the array name as the first parameter, then every parameter after that is a value to add.

However, for your code, I wouldn't use push() at all (if it even exists). I'd use gfooter.value += '[" ' + URL + ' "," ' + name + ' "," ' + descs + ' "],'; (Note: I just put in the spaces to show the breaks between the quotes; also, I'm assuming that you're adding a set of values into the global footer in an admin-editable code.)


Well I could do that, but Id have to find the array in the string(thanks Chris), first. :) Thanks guys, I have to think about this one :P

You have a couple of choices as I see it. Use the replace method on the global footer textarea to replace the string array in there and add more so it can be read on other pages. Or you could pull the array out using regular expressions then use an eval() on the string you pulled out and push from there. Then you could make that into another string and use replace. Either way you will be using replace and the second way is just longer and more trouble. I would go the first route as it's more direct. :P
Greg says:
Coding music...
Greg says:
Hmm...
Greg says:
I wouldn't rule it out. :P
Chris 3.0 [New features? Yes.] says:
:P
Greg says:
If you think about machine code it's a bunch of 1s and 0s
Chris 3.0 [New features? Yes.] says:
Anything is possible.
Greg says:
Yeah try to code Metallica
Chris 3.0 [New features? Yes.] says:
:P Yeah, I'll get right on that... right after I learn to fly.

newBookmarkLockedFalling