The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How Get First Char from HTML textbox and assign to hidden?
rixtertrader
post Oct 1 2020, 12:28 AM
Post #1





Group: Members
Posts: 1
Joined: 1-October 20
Member No.: 27,567



I have an old PHP site that has a HTML form. When you fill out this form and click Submit, it sends me an email using text from a template filled out by Formmail.

This template allows me to autofill using the form field names.

For example, $firstname $lastname

So when the user fills out the form and clicks submit, I will get the first and last name that was entered emailed to me.

What I'd like to be able to do is to use the first letter of the firstname and lastname and combine with some numbers on this template.

For example, if the user entered Burt Reynolds, I'd like to be able to create text that reads "BR38768", where you see B and R being the first character of first and last name.

This template gets the values from $firstname and $lastname from the HTML form fields.

The only way I can get values to the template is to create my own form fields, such as Type="Hidden", though these have to be passed via another hidden type with name "derive_fields".

If I could just assign the value to my two hidden fields firstnameChar and lastnameChar using the first letter from firstname and lastname, I could get this to work.

But I can't figure out how to set the value of those hidden fields to hold the first letter of the firstname and lastname fields before the Submit is hit.

The onSubmit is already set to "return mastervalidate(this);" so I don't have that to place a function. This triggers the Formmail if validation is True.

I have a novice experience with this so the answer isn't obvious to me.

Any help? TIA


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 1 2020, 12:44 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



I think it could be done with some JS tricks. But wouldn't a better way be to change the PHP script so it grabs the initials and assigns them to a new variable? Where does the number come from BTW?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 1 2020, 07:21 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



It's not the old insecure Matt's Formmail you're using?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 05:58 AM