I am trying to make a function like this but i need the parameters to be a string .

function viewrestaurant(int)
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)



this works find when i use the function i can run it fine but only as an int as seen here

function viewrestaurant(int)

How could i replace int with a string? it doesnt work, nor a var. thanks all for your help.

Javascript function parameters are untyped. 'int' in your case is the name of the variable, not the integer type.

pritaeas is right. But if you want to change it from 'int' to something else, you have to change it in the AJAX function

function viewrestaurant(int){if (window.XMLHttpRequest)

and here to reflect:


thank you where is the ajax function?

Im not doing the work for you. I only helped you out on what you needed.

I am trying to make a function like this but i need the parameters to be a string

just apply it to your code

Do you just need more variables in your function?

I just need a string where it says int, but only an integer works.
When i try to do like this,


int doesn't become "name" only a number will work there, so i was wondering why the function params wont accept a string. thanks

dont use quotes in your function. do you even understand this or did you just copy the code and now you want people to solve it for you?

name is a variable. so if you have a function like

<a href="javascript:viewrestaurants(2)">view</a>

the 2 would be passed to the function viewrestaurants(int) because the function requires a variable which in this case is int or name or whatever you want it to be.

try this

<script type="text/javscript">
function show(var1, var2) {
    alert("I can count: " +var1+" "+var2);
<a onclick="show('Hey','Whats up')">click</a> 
<a onclick="show('1','2')">click</a>