squiblo Posted June 21, 2010 Share Posted June 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
squiblo Posted June 21, 2010 Author Share Posted June 21, 2010 Any ideas? Quote Link to comment Share on other sites More sharing options...
haku Posted June 21, 2010 Share Posted June 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
squiblo Posted June 21, 2010 Author Share Posted June 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.