• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 66
  • Last Modified:

get text from inpu

Hi,

I am trying to get the text from an input of type text like so:
<input type="text" id="inpAvg" name="gasaverage" value="" style="width: 60%;" />

Open in new window

with this jQuery
var avg = $("#inpAvg").val();

Open in new window

but it returns an empty string no matter what I put in the input.

What is wrong?

Best regards
RTSol
0
RTSol
Asked:
RTSol
  • 4
  • 2
  • 2
  • +1
2 Solutions
 
leakim971PluritechnicianCommented:
http://jsfiddle.net/zrej6aj8/

<input type="text" id="inpAvg" name="gasaverage" value="IM NOT EMPTY" style="width: 60%;" />
0
 
ElxnbossCommented:
You should remove the value="" part of the input HTML.
0
 
RTSolAuthor Commented:
It's very dtrange but nothing of the above works fro me. The input resides inside a view in a hybrid mobile app. I am going nuts. Any ideas?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ElxnbossCommented:
Are you sure you don't have another element with the same ID?  Sounds like you have quite a bit of code.
0
 
RTSolAuthor Commented:
It's a lot of code but the id is unique
0
 
leakim971PluritechnicianCommented:
provide a link this website
0
 
RTSolAuthor Commented:
Well - it is a mobile app so I can't.
0
 
Hans LangerCommented:
obviously you are getting a different element.
- try using a different ID,
- try getting it by the name $("[name='gasaverage']").val()
- be sure that the "val()" and "$" function are not overwritted. Use document.getElementId('inpAvg').value
- are you using iframes? or frames?
0
 
RTSolAuthor Commented:
Hi guys,

Sorry for the delay. It actually was a problem with multiple IDs. I was using requirejs and didn't realize that all the html was lodaed when the app was run. stupid of me - thanks.

Best regards
RTSol
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now