Jump to content

Javascript - 'Submit' in New Windon

Recommended Posts


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?

Link to comment
Share on other sites


Try this code:

<input type="button" value="Search"
onclick="window.open('https://b4.caspio.com/dp.asp?AppKey=XXX&Client_ID=' + document.getElementById('cbParamVirtual1').value)">

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.

Link to comment
Share on other sites

  • 2 weeks later...

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 (?).


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.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...