Solved

passing multiple parameters in url using JS

Posted on 2009-04-09
2
2,428 Views
Last Modified: 2013-12-16
I've been using  the code below to pass one variable from one page to the other:

I'm using Coldfusion flash forms on the page. The page calls the "tagging" cfsavecontent:
<cfsavecontent variable="tagging">
      var somevar = poID.text;
      getURL("javascript:newWin3('" + somevar + "');")
</cfsavecontent>

The cfsavecontent uses the script below to open an new window and pass the variables:

<SCRIPT type="text/javascript">
void function newWin3(poID){
var MyPage = "tagging.cfm?poID=" + poID;
window.open(MyPage,'mywindow', 'toolbar=no, height =750, width = 870, scrollbars=yes');
}
</SCRIPT>

The code doesn't work when passing multiple variables:
I've tried:

<cfsavecontent variable="attachmnt">
  var somevar = poID.text;
  var somsub = subject.text;
  getURL("javascript:newWin2('" + somevar,  + '&' + somsub +"');")
</cfsavecontent>

<SCRIPT type="text/javascript">
void function newWin2(poID, subject){
var MyPage = "attachments.cfm?ID=" + poID + "&sb=" + subject;
window.open(MyPage,'mywindow1');
}
</SCRIPT>

Is there a way this code can be modified so that it can pass multiple variables to another page?

I'd appreciate your help!

0
Comment
Question by:HumanScaleDev
2 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 400 total points
Comment Utility
try:

<cfsavecontent variable="attachmnt">
  var somevar = poID.text;
  var somsub = subject.text;
  getURL("javascript:newWin2('" + somevar + "', '" + somsub +"');")
</cfsavecontent>

0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 100 total points
Comment Utility
Change the & ampersond to , comma as proposed above and change slightly your JavaScript function:
<SCRIPT type="text/javascript">

// void is in JavaScript not required.

function newWin2(poID, subject){

  var MyPage = "attachments.cfm?ID=" + escape(poID) + "&sb=" + escape(subject);

  var nw=window.open(MyPage,'mywindow1','top=40,left=40,height=600,width=800');

  nw.focus();

}

</SCRIPT>

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now