HMRC Posted April 21, 2009 Share Posted April 21, 2009 Im trying to reference a field on my HMTL form and pass it onto a variable before I post the form but I just can make it out: This is what I have and im getting a parse error $TransType = ['TransactionType']; TransactionType is the field name on my form Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/154999-referencing-a-field-on-an-form-html-form/ Share on other sites More sharing options...
Axeia Posted April 21, 2009 Share Posted April 21, 2009 What language are we talking about here? Javascript or PHP? Seeing the $ infront of the variable I'll just assume PHP. Your form will be send to whatever you filled in under the forms action attribute. So on that page (depending on whether your form was set to post or get) you'll need to get the information via $_GET or $_POST. So most likely you'll want to use something like [/code]$TransType = $_POST['TransactionType'];[/ Sound like you've somewhat of an idea of how it should work and are in need of an example so I suggest a quick read over at http://www.w3schools.com/php/php_forms.asp Quote Link to comment https://forums.phpfreaks.com/topic/154999-referencing-a-field-on-an-form-html-form/#findComment-815529 Share on other sites More sharing options...
HMRC Posted April 22, 2009 Author Share Posted April 22, 2009 Thanks, I know how to assign the variable if im to assign from a different file via a $_POST or $_GET but maybe let me explain what I want to do. I have a combo box called "TransactionType" with values "Receipt","Issue" and "Adjustment" My form action is assgned to a variable "$NameOfFile" So for instance I choose "Receipt" as my TransactionType, I want to pass this value "Receipt" into the variable $TransType before I even post the form. This, I think will then enable me to pass a value to the form action variable "$NameOfFile" as to which file is to be called now. So ideally I want to pass the values on my current form before I post. Something like $TransType = document.transactionType.value; $TransType = value of transactionType; This is where im stuck. I have checked many postings but I have not come accross anything like it Thanks HMRC Quote Link to comment https://forums.phpfreaks.com/topic/154999-referencing-a-field-on-an-form-html-form/#findComment-816201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.