User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Anyone See a prob with this js? Page [1]  
mytwocents
All American
20654 Posts
user info
edit post

Since I'm not a js expert....it looks to me like there are some basic problems with this script....but since you guys are better at this than me..... I mean it looks like there are some quotation issues...bracket issues..... I don't know...what do you see?


<script type="text/javascript">
function addToRegistry() {
var q = "add= ";
for(i=0; i{
if(document.cart_quantity.elements[i].type!="checkbox) {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
else {
if(document.cart_quantity.elements[i].checked==true) {
q += "&" +
document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
}
}
window.location = "registry.php?"+q;
}
</script>


[Edited on June 26, 2009 at 4:30 PM. Reason : ]

6/26/2009 4:15:31 PM

agentlion
All American
13936 Posts
user info
edit post

use the [ code ] tag, plz (remove the spaces)

6/26/2009 4:25:26 PM

mytwocents
All American
20654 Posts
user info
edit post

not sure which spaces you were referring to but I was attempting to keep the code as it was given to me in case that's where any of the problems lie...

6/26/2009 4:31:05 PM

Ernie
All American
45943 Posts
user info
edit post

1. It would help if you told us what you're trying to do
2. Line 4 is boned: for(i=0; i
3. Line 6: "checkbox

[Edited on June 26, 2009 at 4:49 PM. Reason : "]

6/26/2009 4:39:01 PM

agentlion
All American
13936 Posts
user info
edit post


<script type="text/javascript">
function addToRegistry() {
var q = "add= ";
for(i=0; i
{
if(document.cart_quantity.elements[i].type!="checkbox) {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
else {

if(document.cart_quantity.elements[i].checked==true) {
q += "&" +
document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
}
}
window.location = "registry.php?"+q;
}
</script>


see "edit post" for this post to see how the [ code ] tag works. It allows you to paste in spaces and tabs into your code, and the font is monospaced


[Edited on June 26, 2009 at 4:41 PM. Reason : .]

6/26/2009 4:39:04 PM

Tiberius
Suspended
7607 Posts
user info
edit post

I see a woman behind the keyboard, that's usually not a good sign

6/26/2009 4:46:47 PM

mytwocents
All American
20654 Posts
user info
edit post

my apologies agentlion....I didn't know the code tag allowed you to do that....but thanks


Ernie...well it's part of a bigger script that is a mod to something else but the basic script looked like it was missing something and I think the problem is that there needed to be a quotations mark after the checkbox in line 6.

Now there are other issues but I think they need to be sorted out by the guy who did this mod to begin with.

6/26/2009 4:52:03 PM

mytwocents
All American
20654 Posts
user info
edit post

f'ing double post...sorry

[Edited on June 26, 2009 at 4:52 PM. Reason : ]

6/26/2009 4:52:03 PM

Ernie
All American
45943 Posts
user info
edit post

Quote :
"it's part of a bigger script that is a mod to something else"


Oh, that clears things up

And, yeah, it's not gonna run with the broken for loop or missing quotes

6/26/2009 4:54:01 PM

BigMan157
no u
103354 Posts
user info
edit post

also the string concatenations in the if statements probably won't work if there are line breaks between the +es

[Edited on June 26, 2009 at 5:05 PM. Reason : also it looks like your query string is going to start out "and= &"]

6/26/2009 5:03:47 PM

Ernie
All American
45943 Posts
user info
edit post

This is why you don't use odesk

6/26/2009 5:07:08 PM

mytwocents
All American
20654 Posts
user info
edit post

Didn't use odesk...don't even know what it is....

Since you guys seem to want the full story:

I have a site which makes use of the Zencart shopping cart installation. I've made a lot of mods to the basic install already but I wanted to add a gift registry. The problem is that there is only one person who created a registry specifically for zencart...and because of a previous mod I made, his script was not set up to handle this so he's been working on it for a few weeks and today sent me the files to try out...

As for the broken loop.....since I'm not sure how it is supposed to look, or how it's supposed to relate to the other parts of the script, I'm going to have to ask him on monday.

6/26/2009 5:20:50 PM

DPK
All American
2390 Posts
user info
edit post


function addToRegistry() {
var q = "add= ";
var e = document.cart_quantity.elements.length;
for(i=0; i<=e; i++) {
if(document.cart_quantity.elements[i].type!="checkbox) {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
else {
if(document.cart_quantity.elements[i].checked == true) {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
}
}
window.location = "registry.php?"+q;
}

6/26/2009 5:25:06 PM

mytwocents
All American
20654 Posts
user info
edit post

oops.....just realized that the php didn't make it through initially....though not sure if it would make a difference to the js part of it but there is supposed to be a

var q = "add= php=$_GET['products_id']php";
in line 3...

does this make a difference for the loop?

[Edited on June 26, 2009 at 5:29 PM. Reason : ]

6/26/2009 5:29:28 PM

Ernie
All American
45943 Posts
user info
edit post

No, the for loop needs three parameters: an initial value, an ending value and an increment value. Yours seems to have been chopped off.

6/26/2009 5:38:48 PM

mytwocents
All American
20654 Posts
user info
edit post

OK.....I'm going to try this another way.....

anyone see how the following 2 javascripts could be combined?
(and I know you guys said there were problems with this first one, but all I can tell you is that it works, and the other way doesn't)


<script type="text/javascript">
function addToRegistry() {
var q = "add= ";
for(i=0; i{
if(document.cart_quantity.elements[i].type!="checkbox") {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
else {
if(document.cart_quantity.elements[i].checked==true) {
q += "&" + document.cart_quantity.elements[i].name + "=" +
document.cart_quantity.elements[i].value;
}
}
}
window.location = "registry.php?"+q;
}</script>


[Edited on August 5, 2009 at 3:07 PM. Reason : mother fucker]

8/5/2009 3:02:40 PM

mytwocents
All American
20654 Posts
user info
edit post

ok....apparently there is a problem with the g'damn code cause it's fucking up this page....I'll make a text page of the second script......
http://www.thespinzone.com/temp/twwjs.txt

8/5/2009 3:12:01 PM

Grandmaster
All American
10829 Posts
user info
edit post

I think you should call Sun and Netscape and pretend to be a reporter for a very prominent news station in the area. Then you can pit them against each other until they fix the script for you under warranty and free of charge.

8/5/2009 3:14:44 PM

mytwocents
All American
20654 Posts
user info
edit post

last month called.....it wants it's thread back

8/5/2009 3:16:14 PM

mytwocents
All American
20654 Posts
user info
edit post

OK....how bout this.....since the way the store is set up (mysql wise)....every product has an id as does every option, and since the default option id = "0", is there anyway to add into that initial script something that says, 'if that option id=0, then give an alert, otherwise add it to the registry?

And example of how something gets added to the registry is the following:

if there is an actual option then when relating to "registry.php?"+q, the q would be something like:
37&id[4]=366&cart_quantity=1&products_id=37 (where the product id is 37 and the option id is 366)

and if there WASN'T such an actual option, it would look like:
37&id[4]=0&cart_quantity=1&products_id=37 (where the product id is 37 and the option id is 0) and it is in this case that I would want that alert....

8/5/2009 6:17:52 PM

 Message Boards » Tech Talk » Anyone See a prob with this js? Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.