As many of you might know, i totally suck at regex..so would really appreciate some help here.
Basically i have a html page with a lot of textboxes,radios,checkboxes etc
i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox.
for example here are 2 checkboxes:
so if i want the second checkbox code i was thinking of something like this:
> Hey guys,
>
> As many of you might know, i totally suck at regex..so would really appreciate some help here.
>
> Basically i have a html page with a lot of textboxes,radios,checkboxes etc
> i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox.
> for example here are 2 checkboxes:
>
>
>
>
>
>
>
> so if i want the second checkbox code i was thinking of something like this:
>
> $the_name="something2";
> $the_value="2";
> $fetched=getCheckboxFromHTML($the_name,$the_value);
>
> and then if successful the variable $fetched would contain
>
>
> the idea is that i would use the contents of $fetch to add some code before the end just before the greater than symbol, and do a str_replace().
>
> What do you think? Critique of my logic above too is welcome!
>
> Thanks!
> Ryan
>
>
>
>
Rather than a regex, you're probably better off using something like
DomDocument, where you can iterate over all of the input elements in the
document, and check the attributes of each one to check if they match
your criteria.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-JHTibqPZsecRPY2OdDhr--
Re: Help with regex (search/replace) please
am 06.02.2010 16:40:11 von Phpster
Why not just pass the value in the onclick?
Onclick=doSomething(this);
Would give you simple access to all the properties of that element.
This.value would pass just the value.
Bastien
Sent from my iPod
On Feb 6, 2010, at 9:43 AM, Ryan S wrote:
> Hey guys,
>
> As many of you might know, i totally suck at regex..so would really
> appreciate some help here.
>
> Basically i have a html page with a lot of
> textboxes,radios,checkboxes etc
> i need your help in the form of a regex so that when i give it the
> name and value it gives me the entire code of that checkbox.
> for example here are 2 checkboxes:
>
>
>
>
> onClick="javascript_code_etc()" onSomething="lots of js cod here()" />
>
>
>
> so if i want the second checkbox code i was thinking of something
> like this:
>
> $the_name="something2";
> $the_value="2";
> $fetched=getCheckboxFromHTML($the_name,$the_value);
>
> and then if successful the variable $fetched would contain
>
> onClick="javascript_code_etc()" onSomething="lots of js cod here()" />
>
> the idea is that i would use the contents of $fetch to add some code
> before the end just before the greater than symbol, and do a
> str_replace().
>
> What do you think? Critique of my logic above too is welcome!
>
> Thanks!
> Ryan
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Rather than a regex, you're probably better off using something like DomDocument, where you can iterate over all of the input elements in the document, and check the attributes of each one to check if they match your criteria.
@Ash, You're kinda reading my mind... i did do this in domDocument but it didnt work out so well... so now am trying to do this in a diff way.
Is it ok if i send you the code via an attachment? it is REALLLL messy code right now though.
@Bastien, you're talking client side... i need to do this server side as then i am writing the results to a file which is going to be used as a template in other scripts.
> Hey Ash,Bastien!
>
>
> Rather than a regex, you're probably better off using something like DomDocument, where you can iterate over all of the input elements in the document, and check the attributes of each one to check if they match your criteria.
>
>
> @Ash, You're kinda reading my mind... i did do this in domDocument but it didnt work out so well... so now am trying to do this in a diff way.
> Is it ok if i send you the code via an attachment? it is REALLLL messy code right now though.
>
> @Bastien, you're talking client side... i need to do this server side as then i am writing the results to a file which is going to be used as a template in other scripts.
>
> Thanks!
> Ryan
>
>
>
I'm not going to be about for most of the weekend now, so it might be
better putting the code in something like pastebin and posting a link to
it on here!
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-kgzY+ciN06r8YwmgDJ3O--
Re: Help with regex (search/replace) please
am 06.02.2010 18:35:21 von Al
have you looked at the Pear html_QuickForm2 set?
On 2/6/2010 9:43 AM, Ryan S wrote:
> Hey guys,
>
> As many of you might know, i totally suck at regex..so would really appreciate some help here.
>
> Basically i have a html page with a lot of textboxes,radios,checkboxes etc
> i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox.
> for example here are 2 checkboxes:
>
>
>
>
>
>
>
> so if i want the second checkbox code i was thinking of something like this:
>
> $the_name="something2";
> $the_value="2";
> $fetched=getCheckboxFromHTML($the_name,$the_value);
>
> and then if successful the variable $fetched would contain
>
>
> the idea is that i would use the contents of $fetch to add some code before the end just before the greater than symbol, and do a str_replace().
>
> What do you think? Critique of my logic above too is welcome!
>
> Thanks!
> Ryan
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Help with regex (search/replace) please
am 06.02.2010 21:44:20 von PHP Gen
@Al,
> have you looked at the Pear html_QuickForm2 set?
Actually nope, whats it about? just did a google search and found it on the php site but no example code around so dont really have a clue.
@Ash,
Pastebin! Of course, why didnt i think of that... will do!
Actually, just did so that i wouldht have to double post to the list.
heres the pastebin url
http://pastebin.com/m18b6fb86
I cleaned up a lot of surrounding code so its a bit more readable leaving only the relevant code.
Theres one thing quite strange that i have to mention, this code: