Problem with javascript to replace or remove text

I have written a javascript function to replace text:

function replaceString(completeString,removeString,replaceValue){

//function replaces values in a string - if replaceValue is an empty string the function is used to remove elements from a string

return completeString.split(removeString).join(replaceValue)

}

it works as intended.

My problem is that I use this function to remove a member of a list. This works fine (as I have done an alert to tell me the value of the field) however, when I refresh the page (using another javascript function so as not to call the OnSubmit event):

function refreshFormFields(){

//function used to refresh fields without invoking the onSubmit event

document.forms[0].__Click.value="$Refresh";

document.forms[0].submit();

}

(this also works as intended)

and look at the value of the replaced field in the onload event (just using an alert to see the value) it has the old value ie with the element I thought I’d removed still in the list.

Not really sure why this isn’t working and would be grateful for any assistance.

Subject: problem with javascript to replace or remove text

What are the field attributes? Is it disabled?

Subject: problem with javascript to replace or remove text

Not sure if this helps, but:onclick=“void(document.formname.fieldname.value=‘’);”

you can also add this to a non-submitting button as such:

edit: should have mentioned you can set the field to any value you want such as:

void(document.formname.fieldname.value=‘blah’);

Subject: RE: problem with javascript to replace or remove text

The code I have is already in the onclick event. I have an assignment of a value to another field and that works fine (ie it doesn’t revert to the pre-refresh value).

I don’t know if there is something in the document context that puts the original value back.

The value is changed in the field (I have done an alert to give the field value), it’s just after the refresh that the old value comes back.

I should add I have another button, in which I have javascript, to add a user to a list and this works fine. Assigning values isn’t really the problem.

Thank you for responding.

Subject: solved problem with javascript to replace or remove text

I originally had the assignment of the return value from the replace function set as follows, using variables:

varForm = document.forms[0];

varReaderList = document.forms[0].ReaderList.value;

varReaderList = replaceString(varReaderList,varRemove,“”);

I changed the assignment to:

varReaderList = document.forms[0].ReaderList;

varReaderList.value = replaceString(varReaderList.value,varRemove,“”);

and it works perfectly.

I was simply updating the variable rather than the object. I was confusing variables holding an object reference rather than a value. Obviously my original assignment was for the object value not the object itself.