Jump to content

Getting hidden input value from string


squiblo

Recommended Posts

Lets say I have this variable containing this string..

 

var hidden_input = "<input type='hidden' name='age' value='10yearsold'>";

 

How can I get the value of the hidden input from the variable?

 

Thanks.

Link to comment
Share on other sites

I think this should do it for you:

 

var hidden_input = "<input type='hidden' name='age' value='10yearsold'>";
var match = /value='(.+?)'/.exec(hidden_input);

 

If it works, match[1] will contain the value. I didn't test it though.

Link to comment
Share on other sites

Sorry Haku, I have just realised that the string could contain more than one hidden input so I want to get the value depending on which value I want to get by the name.

 

^^

That sounds confusing sorry, If you don't understand I'll try again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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