Jump to content
  • 0

Using first letter of field value within URL parameters


perdman

Question

I am trying to use Javascript to call the value of a field (First_Name),

Then trim this field down to the first letter of field value,

Then write the result back to a hidden database field.

If I can get this accomplished, I will then be able to use the field value within URL parameters to call specific records, whose First_Name field starts with the specified letter.

I am using the following code, with no luck yet:

function getfirst()

{

var firstletter = document.getElementById("InsertRecordFirst_Name").value;

var fl = (firstletter.charAt(0)).value;

document.getElementById("InsertRecordfl").value=fl;

}

document.getElementById("caspioform").onsubmit=getfirst;

Anyone have any suggestions?

Thanks in advance.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The charAt() method returns the character at the specified index in a string.

You should replace charAt(0).value at charAt(0). Add this script to HTML Block. It must be the last element on the page.

<script type="text/javascript" language="JavaScript">
function getfirst()
{
var firstletter = document.getElementById("InsertRecordFirst_Name").value;
document.getElementById("InsertRecordfl").value = (firstletter) ? (firstletter.charAt(0)) : '';
}
document.getElementById("caspioform").onsubmit=getfirst;
</script>
Hope this helps
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...