Jump to content

DOM


Ninjakreborn

Recommended Posts

How do I access strictly to a form field. I am trying to do something with javascript and php, I have a function created in javascript, that I am trying to secure, then I am going to use it with php to validate, what do I do to access a form field. Right now I have a function with onsubmit() and I called it, but I am not accessing the form fields right I tried multiple ways, because I also need to use this to create some classes in php, I tried
for instance my firstname field
I tried test form is the name of my form by they way
document.testform.firstname
I tried
document.testform.['firstname']
document.testform.["firstname"]
I even tried
window.document.testform.firstname
window.document.testform.['firstname']
and
window.document.testform.["firstname"]
nothing here gives me access to that form field. How do I correctly gain access to this,
Link to comment
Share on other sites

can anyone help with this, it's the only thing holding me back< I am still trying to figure out something but everything I try is not working, I can't get the function to access the form field no matter what I put in, I know my own submit works, I have tested that, it has something to do with me accessing the fields, my function structure is good, I triple checked it to make sure I set up everything the only thing I can think of is I am not accessing the form field right.
Link to comment
Share on other sites

okay dude seriously, this is like how many times I and other people have told you that you are asking javascript questions in a php forum. please go to javascript forum to get javascript questions answered. I would be more than happy to help you if i knew javascript. but i don't. that's why i'm here. and so is everybody else.

but nonetheless, i googled "javascript get form value" (google is your friend too) and i think what you are looking for is something along this line:

variablename=nameofform.nameoffield.value;


example:

<form name="blah" method="post">
enter fruit<input name="fruit">
</form>

and then

<script = 'javascript'>
fruitchoice = blah.fruit.value;
document.write(fruitchoice);
</script>
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.