Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.submit problems

    I have a form:
    rst("productversion") - is a loop from results from db query


    <form name="amount<%=rst("productversionid")%>" method=get action="viewcart.asp" >

    <select name="selRadio<%=rst("productversionid")%>" onChange="javascript: document.amount<%=rst("productversionid")%>.txtPrice<%=rst("productversionid")%>.value = this.options[this.selectedIndex].value;" class="dropdown">

    <option value = "-" selected ></option>
    <% bunch of sql junk in a loop for more option %>
    </form>

    <a href="javascript: addtocart(document.amount<%=rst("productversionid")%>);" target="_parent" class="left_headers_white">ADD TO CART</a>

    function addtocart(e,productversionid)
    {
    var temp = eval('e.selRadio'+productversionid+'.value');
    if (temp == "-")
    {
    alert('You must select a Quantity for this Product');
    }
    else
    {
    e.submit();
    }

    }

    for the life of me I cannot get the bast'd to submit ... it simply does nothing... not even reload the current page... it does make a "click" noise
    ... wahoo ... any suggestions?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    function addtocart(e,productversionid)
    That suppose you must have 2 parameters

    function foo(param1,param2)

    but it looks like you fired onevent with only one parameter, the form's reference:

    addtocart(document.amount<%=rst("productversionid")%>)

    Thus, your second parameter used in function, productversionid has no input...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <a href="javascript: addtocart(document.amount<%=rst("productversionid")%>);" ...
    should read:
    <a href="javascript: addtocart(document.amount<%=rst("productversionid")%>,<%=rst("productversionid")%>);" ...

    that's my bad I have that in my code I just copied it over wrong because I wanted to make it simpler

    but even if it did pass that in productversionid would be null, not pass the if case, go into the else and should submit the form ...
    no worky

  • #4
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i've tried
    document.form[whatever].submit();
    didnt work
    i even tried to just change the page
    window.location.href = url that I want to go to
    didnt work either ...

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It may be more helpful if you posted the code of the page after it has been parsed. But the problem may lie in the form name....

    name="amount<%=rst("productversionid")%>"

    Try changing the double quotes used to enclose the form name with single quotes....

    ......Willy

  • #6
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <form name="amount3" method=get action="viewcart.asp" >

    <select name="selRadio3" onChange="javascript: document.amount3.txtPrice3.value = this.options[this.selectedIndex].value;" class="dropdown">
    <option value = "-" selected></option>
    <option value="112.50"quantity = 50 >50</option>
    <option value="337.50"quantity = 150 >150</option>
    <option value="562.50"quantity = 250 >250</option>
    <option value="787.50" quantity = 350 >350</option>
    <option value="1,012.50" quantity = 450>450 </option>
    </select>

    <input name="txtPrice3" type="text" value="" size="8" onFocus="this.blur();" class="dropdown"></form>

    <a href="javascript: addtocart(document.amount3,3);" target="_parent" class="left_headers_white">ADD TO CART</a>


    tried with and without quotes everywhere I can think of... thanks for the try

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It worked for me using google as the form action.....

    Code:
    <script type="text/javascript">
      function addtocart(e,productversionid){
       var temp = eval('e.selRadio'+productversionid+'.value');
        if(temp == "-"){
           alert('You must select a Quantity for this Product');
        }  else{ e.submit() };
      }
    </script>
    </head>
    
    <body>
    <form name="amount3" method="get" action="http://google.com" >
    <select name="selRadio3" class="dropdown"
    onchange="document.amount3.txtPrice3.value=this.options[this.selectedIndex].value">
    <option value = "-" selected></option>
    <option value="112.50"   quantity =  50> 50</option>
    <option value="337.50"   quantity = 150>150</option>
    <option value="562.50"   quantity = 250>250</option>
    <option value="787.50"   quantity = 350>350</option>
    <option value="1,012.50" quantity = 450>450</option> 
    </select>
    
    <input name="txtPrice3" type="text" value="" size="8" 
    onfocus="this.blur();" class="dropdown"></form>
    
    <a href="javascript:addtocart(document.amount3,3)"
    target="_parent" class="left_headers_white">ADD TO CART</a>
    .....Willy

  • #8
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not know my friend... still not working ...
    I ended up doing some crazy vbscript and using
    response.redirect and just sending in the variables using ?var=whateve&ect......

  • #9
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but you didn't think of posting the output from the ASP so we could've seen what it was doing wrong...

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts

    Don't use eval

    Code:
    function addtocart(e,productversionid){
       var sel = e.elements['selRadio'+productversionid];
        if (sel.options[sel.selectedIndex].value == "-"){
           alert('You must select a Quantity for this Product');
        }  
        else{ 
          e.submit();
        }
        return false;
      }
    ...
    <a href="#" onclick="return addtocart(document.amount3, 3)" class="left_headers_white">ADD TO CART</a>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •