Jump to content

Referencing a field on an form HTML form


HMRC

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.