This topic is locked

Setting a parameter for an onchange event

10/27/2007 12:07:49 AM
PHPRunner General questions
G
giles author

Hi,
I have a line in a javascript program where I set an onchange event to activate another javascript function...
document.getElementById("value_somefield").onchange = function() {myfunction();};
This works fine however I want to pass that javascript function a text string:
document.getElementById("value_somefield").onchange = function() {myfunction("the string to pass");};
The string needs to change depending on context.
The issue is that the function() {myfunction();}; part of the code is not a text string so I don't seem to be able to manipulate it prior to setting the onchange event.
Any suggestions?

G
giles author 10/30/2007

Found a way around this....
Javascript accesses the document title and makes its decison on what to do based on this...
if (document.title=="whatevertitle")
Guess it could also access a hidden text field on the display.