user961437
user961437

Reputation:

How would I get text from an input 'type=text' element using jquery?

Provided I cannot edit the HTML code at all how would I do this?

<input type="text" id="Identifier"     
class="inputControlFlexWidth" value="" tabindex="9" size="25" 
name="texthole">

I'm guessing this has to be a timed event such as

setInterval(ObserveInputValue(), 100);

Because the input can happen at any time.

I then want to use this text to update a URL.

Thanks.

Edit:

<input id="ServiceRequestEditForm.CustomObject6 Name.hidden" type="hidden" value="" 
tabindex="-1" name="ServiceRequestEditForm.CustomObject6 Name.hidden">

Upvotes: 1

Views: 1759

Answers (3)

Jason Gennaro
Jason Gennaro

Reputation: 34855

One way is

$('#Identifier').blur(function(){
    $(this).val();
});

Explanation: When the input loses focus, grab the value of the field.

Example: http://jsfiddle.net/4DtUh/


EDIT

As per the comments...

@Interstellar_Coder is right about spaces inside the id.

So, instead of using the id as the "hook", you could use the name attribute:

$('input[name="ServiceRequestEditForm.CustomObject6 Name.hidden"]')

Example 2: http://jsfiddle.net/4DtUh/10/

Upvotes: 5

No, nothing so complex. You can just use .val() to get the value. In your code you would do:

$('#Identifier').val()

Take a look at the documentation for val()

Upvotes: 0

aziz punjani
aziz punjani

Reputation: 25776

You can add an event listener for the change event, then do whatever you need to in there.

$('#Identifier').change(function(){
   //do whatever you need to 
}); 

Upvotes: 5

Related Questions