views:

79

answers:

5

I need a bit of help with quotes in javascript function

function jsNewWindow(value){
        //window.open ("http://www.javascript-coder.com","mywindow"); 
        window.open("rpt_Distance.php?POST_IN1="+value+","mywindow","width=800,height=600") ;
    }

thanks!

+3  A: 

"rpt_Distance.php?POST_IN1=" + value, "mywindow", "width=800,height=600"

Matthew Vines
I see two changes here, as compared to other posts so far. A $ was inserted before POST_IN1. And the + after the word value was removed.
DOK
@DOK it appears the question was edited after I posted my answer. I will adjust it to reflect the current portion of the code.
Matthew Vines
+1  A: 
function jsNewWindow(value){
        //window.open ("http://www.javascript-coder.com","mywindow"); 
        window.open("rpt_Distance.php?$POST_IN1="+value,"mywindow","width=800,height=600") ;
    }

I just removed +"

Shoban
Why was this down voted, it looks like it was a correct change as the resulting JS it sntacticaly correct?
David Mårtensson
I made a mistake in my first draft ;-) Net was slow took me few mins to update and someone downvoted. Thanks
Shoban
+1  A: 

It helps if you ask a question, not just post a snippet function. Are you trying to insert actual quotes? If so escape them with '\'.

EDIT: Hats off to Shoban for being able to read minds (and code) :).

josh.trow
This seems to me like a comment, not an answer.
Šime Vidas
I tried to add an answer (escaping quotes), but when I don't know the exact question I generally try to get clarification.
josh.trow
josh.trow only have 46 rep, you need 50 to add comments directly to the question.
David Mårtensson
+1  A: 

You have one +" that must be removed:

window.open("rpt_Distance.php?$POST_IN1="+value+","mywindow","width=800,height=600") ;

must be replaced by:

window.open("rpt_Distance.php?$POST_IN1="+value,"mywindow","width=800,height=600") ;
romaintaz
+1  A: 

This code should read to be correct - leaving out the +" after value

function jsNewWindow(value){
    //window.open ("http://www.javascript-coder.com","mywindow"); 
    window.open("rpt_Distance.php?$POST_IN1="+value,"mywindow","width=800,height=600") ;
}
Serge Meunier