Passing Paramater to Javascript Function

G

Guest

Hi all,

I'm looking for a bit of help if possible with my WSS site using Frontpage
2003
I have a list of events, and each event has a venue. I want the user to be
able to click the venue name, and get a popup with the full details of the
venue (address phone no etc). I've the following javascript function to open
the popup

function openVenueInfo(v)
{
var tmpURL = "venueinfo.aspx?venue="+v;
window.open(tmpURL, "_blank",
"height=200px width=610px top=500 left=300 resizable=no
scrollbars=no");
}

and then I call the function as a hyperlink on the venue name to

javascript:blush:penVenueInfo(x);

if i type 3 instead of the x, the link works perfectly, opens the new popup,
displays the right venue details. If I type 4,5 or any other venue id it
works.
So then I changed the x to be a Field Value (using frontpage 2003 hyperlink
parameters dialog box) to insert venue_id, so the link now looks like this.

javascript:blush:penVenueInfo({@venue_id});

when I save the page the link changes to

javascript:blush:penVenueInfo(%7b@venue_id%7d);

which dosn't work.
I removed the %7, so the link looks like

javascript:blush:penVenueInfo(@venue_id);

and it still dosn't work - I get the popup, but inside is an error telling
me that SQL server may not be started.
I also tried removing the @ - it says venue_id is undefined.
I did a doucment.write (tmpURL), and it shows venueinfo.aspx?venue=NaN, so
it would appear nothing is being passed to the function.

I don't get what I am doing wrong, this seems such a simple thing, but it's
had me stuck for a while now - anybody please help!

Thanks for reading, hope you can shed some light for me

Chris
 
M

MD Websunlimited

Hi NoBag,

The {@venue} is not a valid JavaScript variable name and that is the problem.

If you wish to use a form field then value for the venue you'll have to reference the forms field value.

var fieldValue

<form>
<input type="input" name="venue" value="" onblur="fieldValue = this.value;" >
</form>

<a href="javascript:venue(fieldValue);" >Venue Details</a>
 
G

Guest

Hi Mike,

First of all, thankyou for taking the time to reply to my question - much
appreciated.
I've followed what you put, and now I have a form field box on the page, and
the link underneath. I have to type in the venue number into the form field
box, then click the link and it opens the popup with the venue details.

How do I populate the form field with the {@venue_id}, and remove/hide the
text box from the page?

Sorry if I'm missing something, I am a relative begginer at this stuff.

Thanks again for your help,

regards
Chris
 
G

Guest

Hello again,

I've managed to figure it out, however I was unable to convert the parameter
into a format the javascript function would accept.
The hyperlink now reads

<a title="Click for venue details" onclick="return
!window.open(this.href,'','width=610,height=200,resizable=no,scrollbars=no,toolbar=no,status=no');" href="venueinfo.aspx?@venue_id={@venue_id}">

and this works perfectly!

Thanks for your input Mike, it gave me a fresh look, and indirectly helped
me to come up with the solution i've found.

Thanks again

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top