dank
04-06-2001, 01:01 AM
Here's the gist of the situation; minor issue but more annoying than it deserves to be...[nbsp][nbsp]I'm passing a date and form field name into a JavaScript function to place the date into the form's text box when the link is clicked on.[nbsp][nbsp]The JavaScript function can be accessed from several different forms and for 'multiple' reasons needs to accept differing form field names, so both the field name and the date have to be passed into the function.[nbsp][nbsp]Something like:
function setTodaysDate(varfield,text) {
[nbsp][nbsp][nbsp][nbsp] document.input_form[varfield].value = text;
}
<a href="javascript:setTodaysDate('$field_name','$date')">Use Today's Date</a>
That works just fine, except for the situation when the field name ($field_name) contains a hyphen in it.[nbsp][nbsp]That seems to royally screw up the JavaScript, although I haven't found a reference of what is and is not allowed for JS to pass through, whether it can be escaped (something like addslashes), etc.[nbsp][nbsp]escape(), encode() and the like doesn't seem to fit the bill, and placing varfield in quotes or apostrophes doesn't help.
Any ideas?
Thanks,
Dan
[This message has been edited by dank (edited 04-06-01@12:15 pm)]
function setTodaysDate(varfield,text) {
[nbsp][nbsp][nbsp][nbsp] document.input_form[varfield].value = text;
}
<a href="javascript:setTodaysDate('$field_name','$date')">Use Today's Date</a>
That works just fine, except for the situation when the field name ($field_name) contains a hyphen in it.[nbsp][nbsp]That seems to royally screw up the JavaScript, although I haven't found a reference of what is and is not allowed for JS to pass through, whether it can be escaped (something like addslashes), etc.[nbsp][nbsp]escape(), encode() and the like doesn't seem to fit the bill, and placing varfield in quotes or apostrophes doesn't help.
Any ideas?
Thanks,
Dan
[This message has been edited by dank (edited 04-06-01@12:15 pm)]