Forgive the complete newbie question here – I know this is really basic stuff, but for the life of me I can’t figure it out. Javascript is relatively new to me, and this is the first time I’ve had to do this particular thing.
So, I’m trying to use a Modal to open an iframe – the page itself will have links to several modals, all of which need to be passed a different value. Rather than hardcode each of these, I’m trying to set it up in such a way that one function can be used and the links can pass the values as required.
The code I currently have successfully opens the modal, but a 404 error is inside it – plus the modal title shows + title + – so I guess I’m referencing it wrong (probably in the function?).
Heres what I’ve got, pointers in the right direction would be appreciated!
function openIframe(title,url){
$.modal({
title: '+title+',
url: '+url+',
useIframe: true,
width: 600,
height: 400
});
}
.. and the link:
<a href="#" onclick="openIframe('Process Voucher','a_processvoucher.cfm')">Add</a>
To use the variables, don’t quote them;
titlewas being literally set to the string+title+(and the same forurl).It seemed you were getting confused over the concatenation syntax to join strings and variables; for example, see the following:
… will alert the string
Hi Matt, how are you doing today?