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
https://forums.phpfreaks.com/topic/8600-dom/
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
https://forums.phpfreaks.com/topic/8600-dom/#findComment-31543
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
https://forums.phpfreaks.com/topic/8600-dom/#findComment-31558
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.