Solved

passing multiple parameters in url using JS

Posted on 2009-04-09
2
2,434 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 50

Accepted Solution

by:
Ryan Chong earned 400 total points
ID: 24107882
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
ID: 24140035
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Javascript to set controls visibility 5 34
REGEX HELP 11 43
Is there a way to use PhantomJS on a shared server? 4 17
Jquery Validation Messages Not Showing Up 3 9
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
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 an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

770 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