Please help, simple JS string question

Discussion in 'JavaScript' started by kuser, Aug 1, 2012.

  1. #1
    I would like a function that will redirect my users to a product.php?id=id (where id is the product id)
    Ok...

    So ... the problem is this:

    this will output ... product1, product2

    but if i do something like:


    then it will only redirect to product.php, everything after the ? will be removed. I tried to put \? but still the same.
     
    kuser, Aug 1, 2012 IP
  2. Alejandro131

    Alejandro131 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    3
    Trophy Points:
    21
    #2
    I think this is due to the fact that your code will produce the string:
    product.php?idid
    Code (markup):
    This to the browser would mean to send to the server a variable "idid", which doesn't have a value and thus will be discarded.
    Instead add a "=" sign like this:
    
    function remove(id)
    {  
    
    window.location="product.php?id="+id;  
    
    } 
    
    Code (markup):
    and everything should work fine.
     
    Alejandro131, Aug 1, 2012 IP