/    Sign up×
Community /Pin to ProfileBookmark

opening new windows

this may ramble a bit………

my company supplies product information and pricing cds to customers. the cd is in a web based format and contains one page that is a shopping cart from which they can generate and fax an order. pricing varies between customers depending on how much business they do with us so each cd is unique.

for each part number (there are thousands) i store technical and pricing info in an array inside partnumberinfo.js as follows:

[CODE]partnumber[1] = new Array(“partnumber1″,”description”,”sellprice”,”re-sell price”,”other info”);[/CODE]

also in partnumberinfo.js i have a script to create the shopping cart elements.

now i am trying to reconfigure the cd so that the cart isn’t on one page, but each product description page will contain a price table for each part number related to that product.

so far i have:
*the HEAD tag references shoppingcart.js and partnumberinfo.js.
*
in the page body there is <.DIV id=listprices> inside which an onload function calls partnumberinfo.js that builds a price table for each related part number.
*each table row is configured as a shopping cart element (text box with ‘add to cart’ button).
*
each part number in the table is a link to open a new browser window showing more detailed info about that part number (along with another chance to order – ie ‘add to cart’ button)

i create the links in the price table as follows:

[CODE]<A HREF=java script:void(0)” onclick=”indpage(‘”+partnumber[i][0]+”‘);”>”+partnumber[i][0]+”</A>[/CODE]

which calls:

[CODE]function indpage(param) {
var insertedHTML = “<HTML><HEAD><SCRIPT SRC=”shoppingcart.js” language=”javascript”></SCRIPT><SCRIPT SRC=”partnumberinfo.js” language=”javascript”></SCRIPT></HEAD><BODY>”;

for (i=1;i<partnumber.length;i++) {
if (partnumber[i][0] == param) {
insertedHTML += param+”<BR>”+
“<FORM NAME=order>”+
“<input type=text size=10 maxlength=9 name=QUANTITY onChange=’this.value=CKquantity(this.value)’ value=”1” class=formFields><BR>”+
“<input type=hidden name=”PRICE” value=””+partnumber[i][2]+””>”+
“<input type=hidden name=”NAME” value=””+partnumber[i][1]+””>”+
“<input type=hidden name=”ID_NUM” value=””+partnumber[i][0]+””>”+
“<input type=hidden name=”SHIPPING” value=”0″>”+
“<input type=hidden name=”ADDITIONALINFO” value=””+partnumber[i][4]+””>”+
“<input type=button value=’Add’ style=”font-family: Verdana; font-size: 9px;” onClick=’AddToCart(this.form);’ class=formButton>”+
“</FORM>”;
}
}

var mywin = window.open(“”,””,” width=600,height=300,toolbar=yes,location=no,direc
tories=no,status=yes,scrollbars=yes,resizable=yes,
menubar=no”);
mywin.document.write(insertedHTML+”</BODY></HTML>”);
mywin.document.close();

}[/CODE]

i put the HEAD and SCRIPT ref’s in because i am thinking that since it’s opening a new page it will need the location of the script (i just guessed at this – i don’t know for sure).

here’s the problem:
the price table is created as planned, the part numbers are links and the new page opens displaying the part number and the textbox and ‘add to cart’ button, but i get an error when i try to use the ‘add’ button.

[CODE]Line:1
Char:1
Error:Object Expected
Code:0[/CODE]

any ideas??

all advice is greatly appreciated.

thanks.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJun 11.2004 — Does the button work correctly if you hard-code the HTML that you are trying to document.write()? If so, break up the write() so that you do not have the sequence of letters "SCRIPT" anywhere in the same string (i.e.: "...<SCR" + "IPT>...").

Failing that, try adding "return false" to your link, and get rid of the "javascript:void(0)" (use "#" instead).

&lt;A HREF="#" onclick="indpage('"+partnumber[i][0]+"');return false"&gt;"+partnumber[i][0]+"&lt;/A&gt;
Copy linkTweet thisAlerts:
@ibjdtauthorJun 14.2004 — if i hard code the pages everything works properly.

i tried both suggestions and neither worked.

????

thanks.
Copy linkTweet thisAlerts:
@gil_davisJun 14.2004 — Try upgrading to 4.80
×

Success!

Help @ibjdt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...