nicholasnicola Posted March 20, 2012 Report Share Posted March 20, 2012 Hello, We use Google Sites to host our intranet, and it does not allow Javascript (and thus the standard Caspio embed code). I want to have a search form embedded in the site as an iFrame, but then for the search results to be displayed in a new tab. I have configured both the datapages correctly (ie the first with virtual fields to pass parameters to the second) but I cannot get the button URL in the first to pass the data entered. I am using the following Javascript as a HTML block: onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX?=Client_ID=" + document.getElementById('cbParamVirtual1').value')"> When I use the above code, nothing at all happens. If I use the following code: onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX?=Client_ID=" [@'cbParamVirtual1']"> Then the window opens and the URL is correct, but no parameter is passed. Can someone please help? Quote Link to comment Share on other sites More sharing options...
ShWolf Posted March 22, 2012 Report Share Posted March 22, 2012 Hi, Try this code: <form> <input type="button" value="Search" onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX&Client_ID=' + document.getElementById('cbParamVirtual1').value)"> </form> After XXX value you should use & not ? And there is no need in = before Client_ID, double quote after Client_ID= should be replaced with single quote and there is no need in single quote after .value. Let me know if this helps. Quote Link to comment Share on other sites More sharing options...
nicholasnicola Posted March 25, 2012 Author Report Share Posted March 25, 2012 That worked perfectly, thanks very much! Quote Link to comment Share on other sites More sharing options...
nicholasnicola Posted April 3, 2012 Author Report Share Posted April 3, 2012 Hello, I'm sorry to post again, but I'm having a lot of trouble using this method to pass 3 parameters. I try to do what I think is correct but when I then click submit nothing happens. Can You please write me an example of how to pass 3 parameters? Thank you so much for your help. Quote Link to comment Share on other sites More sharing options...
ShWolf Posted April 10, 2012 Report Share Posted April 10, 2012 Hi nicholasnicola, In the future, please attach the code which doesn't work for you. It is always easier that way. I think the part you're missing is the way URL parameters are normally passed to pages. First, there's a base address of a page. Let's say, https://b4.caspio.com/dp.asp Then, if there are any parameters, you add a question mark (?), the name of the parameter (e.g. AppKey), equals sign (=) and finally, the value of the parameter. So with just one parameter, the query string will look like this: https://b4.caspio.com/dp.asp?AppKey=XXX If there are other parameters you want to add, it's the same process, except that there's an ampersand (&) instead of question mark (?). https://b4.caspio.com/dp.asp?AppKey=XXX&Client_ID=YYY&Param3=ZZZ Also, in javascript you operate with text strings which are enclosed in apostrophes (') or double quotes ("). In javascript, you concatenate (stitch) strings and values with the plus (+) operator. To sum it up - if you need a static parameter, you just write its value directly to the string: onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX&Client_ID=' + document.getElementById('cbParamVirtual1').value) + '&Param1=VALUE1&Param2=VALUE2' " If you need another dynamic value added as a parameter: onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX&Client_ID=' + document.getElementById('cbParamVirtual1').value) + '&Param1=' + value1 "Replace "value1" with the way you're getting the value.Let me know if this helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.