views:

68

answers:

2

Hi, i get the webpage content from an external website using ajax but now i want a function which extract a specific input field value which is already autofilled.

the webpage content is like this:

.........
<input name="fullname" id="fullname" size="20" value="David Smith" type="text">
<input name="age" id="age" size="2" value="32" type="text">
<input name="income" id="income" size="20" value="22000$" type="text">
.........

I only want to get the value of fullname, maybe with some javascript regex, or some jQuery dom parser, i know i can do it easily with php but i want it using Javascript or jQuery.

Note: this inputs are not hosted in my page, they are just pulled from other website through Ajax.

Thanks

+2  A: 

Use jQuery find method like $(response).find('#fullname').val(). Refer jQuery find Documentation here

Teja Kantamneni
+1  A: 

jQuery to the rescue:

var body = '<div><input name="fullname" id="fullname" size="20" value="David Smith" type="text"><input name="age" id="age" size="2" value="32" type="text"><input name="income" id="income" size="20" value="22000$" type="text"></div>';
var selector = 'input[name=fullname]';
alert($(selector, body).val());

EDIT: Example at jsbin.com.

Max Shawabkeh