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. Link to comment https://forums.phpfreaks.com/topic/205423-getting-hidden-input-value-from-string/ Share on other sites More sharing options...
squiblo Posted June 21, 2010 Author Share Posted June 21, 2010 Any ideas? Link to comment https://forums.phpfreaks.com/topic/205423-getting-hidden-input-value-from-string/#findComment-1075090 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. Link to comment https://forums.phpfreaks.com/topic/205423-getting-hidden-input-value-from-string/#findComment-1075095 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. Link to comment https://forums.phpfreaks.com/topic/205423-getting-hidden-input-value-from-string/#findComment-1075102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.