...

View Full Version : page reload and call a function



alex57
02-06-2007, 03:11 PM
Hey,

Is it possible to create an onclick event which reloads the page and passes a parameter into a javascript function automatically?

Any code snippets would be appreciated.

Thank you in advance

LFCFan
02-06-2007, 04:07 PM
If you're trying to do what I think you are then:

<button name = "but1" onclick = "javascript:document.form1.field1.value = "whatever"; window.location.reload()")>Reload Page</button> <!--use a hidden field to store the value of your parameter before the page reloads-->

<body onload = "myScript(document.form1.field1.value)"><!--reference the hidden field's value at load time-->
<script language = "javascript">
function myScript(myParam)
{
alert(myParam)
}
</script>

I think this should work.
HTH
Joe



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum