Shopping cart problems: popup window blank, products being replaced

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • localp
    New Member
    • Jun 2008
    • 8

    Shopping cart problems: popup window blank, products being replaced

    i am creating a shopping cart for a project..

    i have come across few problems where i couldn't find a satisfiable solution .

    the problem in detail;;

    1. in this web site there are several pages , that contains products. and when a user clicks on a product (clicks on a checkbox) the product should go to a shopping cart which is on another page or a pop up window.

    2. when i select the checkbox , the present window gets updated with the product details, and the pop up window open seperately (but blank .. no items are displayed there)

    3. and when i go to another page and click on a product the products i have alreadychosen gets replaced, by the new products.

    i no this is not a good thing to do (i mean asking for help) , but i have tried all, to get this thing work.

    i will enclose my javascript code could you be great enough to check it and tell me where i went wrong ...

    code::::::::::: :::;


    [code=javascript]
    var store= new Array();

    store[0]="these are just data"; // the data are stored in these arrays
    store[1]="jau";
    store[2]="s";
    store[3]="jr";
    store[4]="shiiii";
    store[5]="jpoler";
    store[6]="hhddfl";
    store[7]="jmaddddddder" ;
    function testButton (form){
    window.open ("pl.html","myw indow","menubar =1,resizable=1, width=350,heigh t=250");
    window.write ("<table border = \"1\"" + "width = \"100\">");
    window.write ("<thread> <th width = \"100\"" + "align = \"left\"> Count<th align = \"left\">" + "Frequency</th></thread><tbody>" );

    for (var sha = 0;sha < 100; sha++) {

    if (form.rad[sha].checked)
    { // the array is called so the data is displayed
    //store=sha;
    window.write ("<tr><td>" + store[sha] +"</td><td>"+ sha + "</td></tr>");
    }
    }
    window.write ("</tbody</table>>");
    }
    [/code]
    and this is how i call the product from a submit button ( or even from the check box)
    [html]
    <input type="button" value="hi" onClick="docume nt.testform.sub mit();testButto n(this.form)"/>
    [/html]
    plzzzz help........... .....

    and plzzz reply as soon as posible

    regards
    Last edited by gits; Jun 10 '08, 06:08 PM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You have a number of problems with your code.

    You're submitting the form and then trying to open a popup.

    Secondly, you're not using window.open() properly. See this link.

    Thirdly, look at the proper HTML to use for a table.

    Also window.write should be replaced by win.document.wr ite where win is a reference to the window. You're already opening a file and then trying to write to it. That will also cause problems.

    Comment

    • localp
      New Member
      • Jun 2008
      • 8

      #3
      what should i do.. i went through the link u gave ... but i am still having problems ..

      can u plzzzzzzzzzzzzz z tell me where it went wrong .. and a posible solution for it (i mean the code)

      how should i open the pop up window 1st ( i actually got it from a site )

      i am kind of lost

      plzz help me

      Comment

      • localp
        New Member
        • Jun 2008
        • 8

        #4
        Originally posted by acoder
        You have a number of problems with your code.

        You're submitting the form and then trying to open a popup.

        Secondly, you're not using window.open() properly. See this link.

        Thirdly, look at the proper HTML to use for a table.

        Also window.write should be replaced by win.document.wr ite where win is a reference to the window. You're already opening a file and then trying to write to it. That will also cause problems.
        what should i do.. i went through the link u gave ... but i am still having problems ..

        can u plzzzzzzzzzzzzz z tell me where it went wrong .. and a posible solution for it (i mean the code)

        how should i open the pop up window 1st ( i actually got it from a site )

        i am kind of lost

        plzz help me

        Comment

        • localp
          New Member
          • Jun 2008
          • 8

          #5
          javascript functions

          this is the javascript file ::: i have done some modifications here ... if i remove the comment below i will get a lot of popup windows open .. i want to avoid it . and make the content display on it ..


          for the once who is not getting what i'm trying to do -

          i am trying to create a shopping cart application here using javascript ..
          when the user clicks on the purchaise button the details should be submitted to the cart. and thats why i am using a pop up window.


          there is another problem, when i select an item from one page it gets displayed, then when i go to another page and select another item, the items that i selected in the 2nd page replaces the items in the 1 st page .. it simply does not get appended .. so i want a solution for this also ...


          can some one please alter the code for me .. i am completely lost on this ..

          plus i'm new to this forum thus i have posted 2 questions (both similar kind of ques)

          Code:
          var royal= new Array();
          var store= new Array();
          var stu= new Array();
          
          var t;
          	store[0]="shamil";
          	store[1]="jauffer";
          	store[2]="s";
          	store[3]="jr";
          	store[4]="shiiii";
          	store[5]="jpoler";	
          	store[6]="hhddfl";
          	store[7]="jmaddddddder";
          	stu[0]="jill";
          	stu[1]="j";
          	stu[2]="welle";
          	stu[3]="mal";		
          		
          function testButton (form){
          //window.open("pl.html");
          var s= win.document.write("<table border = \"1\"" + "width = \"100\">");
           var y=    win.document.write   ("<thread> <th width = \"100\"" + "align = \"left\"> Count<th align = \"left\">" + "Frequency</th></thread><tbody>");
                  
              for (var sha = 0;sha < 100; sha++) {
               
                  if (form.rad[sha].checked)
                  {
                  	//store=sha;
                  	royal[sha]=store[sha]
                   t=  win.document.write("<tr><td>" + royal[sha] +"</td><td>"+ royal[sha] + "</td></tr>");
                  }
          
              }
              win.document.write("</tbody></table>");
            win.document.write("<h1> hfhhfhdf " + s  + y + + t +"</h1>");
             
             
           
          }


          plzzzzzzzzzzz help me .. i'm lost
          Last edited by acoder; Jun 11 '08, 08:01 AM. Reason: changed [b] to [code] tags

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by localp
            plus i'm new to this forum thus i have posted 2 questions (both similar kind of ques)
            Which is why I've now merged the threads. Please do not double-post your questions. Keeping to one thread makes it easier to answer.

            Welcome to Bytes! Since you're new, have a quick look at the posting guidelines. One of these is that code is posted in code tags. Thanks!

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Let's try and deal with the problems one at a time.

              When using window.open() to open a blank file to write to, use something like this:
              Code:
              function testButton (form){
              var win = window.open('','someName');
              win.document.write("<table border = '1' width = '100'>");
              There's no 'thread' tag unless you meant a thead tag. Does that make an improvement?

              Comment

              Working...