954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

use text field content as js function param

I'm sure this has an easy answer, but I don't know it.

so I have a widget that will let you get alerts texted to a phone. I am trying to store the info, but I can't get the user's input into my javascript function shown below:

onClick="collect('info', 'nname=' + document.getObjectByID('Nname').value + ';num=12345;


How can I get the content as a string of a text field and use that in my function? Like I said, this is probably a relatively easy question for most, but I cannot figure it out :/

FALL3N
Junior Poster in Training
84 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

I think your method signature is something like following:

function collect(a,b,c)


the onclick should be like

onclick="collect('info', document.getObjectByID('Nname').value, 12345)"

You do not have to pass the parameters as you passing GET variables in http requests

niranga
Junior Poster
163 posts since Apr 2010
Reputation Points: 21
Solved Threads: 21
 

Shouldn't it be getElementById, not getObjectByID?

stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

Yep..!! my mistake... it should be getElementById

niranga
Junior Poster
163 posts since Apr 2010
Reputation Points: 21
Solved Threads: 21
 

omg thank you so much! I spelled 'element' wrong. I am stupid. Anyway, thanks again!

FALL3N
Junior Poster in Training
84 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

Nice..!! :)

niranga
Junior Poster
163 posts since Apr 2010
Reputation Points: 21
Solved Threads: 21
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: