Member Avatar for feoperro

Hi,

Can someone please tell me what the correct syntax for this is... I've tried everything.

parent.TopFrame.document.FormName.inputAreaName.value =(tableName.rows[1].cells[0].innerHTML).trim();

It works without the trim() function, as soon as I put it in, it throws an error and stops working.

Thanks,
-Ash

I think what you want to trim goes inside the brackets

so something like
trim(tableName.rows[1].cells....)

Javascript strings don't have a trim function, to add one you can do something like

String.prototype.trim = function ()
{
  return this.replace(/^\s+|\s+$/, '');
};

somevar = "I have a string with trailing spaces       ";
somevar_trimmed = somevar.trim(); // "I have a string with trailing spaces"

// So yours will be
parent.TopFrame.document.FormName.inputAreaName.value = tableName.rows[1].cells[0].innerHTML.trim();

Quite right, sorry had my PHP head on

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.