Thread

Posted on Mon Oct 16 13:38:15 2006 by marcolz
Dinamically setting form action
Hi, I need to dinamically change the action of a form. Any hints? Thanks. Marco
Direct Responses: 3266 | Write a response
Posted on Mon Oct 16 20:08:45 2006 by gdakram in response to 3264
Re: Dinamically setting form action
If I am understanding you correctly that is -
1. Copy the html content into a variable
2. Do regex substitution to change your form action inside that variable
3. Update the mechanize object with that variable

For example -
$content = $mech->save_content(); $content =~ s/(form.+?action=").+?(")/$1<YOUR DESIRED ACTION>$2/i; $mech->update_html($content);

Hope that helps!
Direct Responses: 3272 | Write a response
Posted on Tue Oct 17 14:30:19 2006 by marcolz in response to 3266
Re: Dinamically setting form action
Hi, great help! I didn't know about update_html(). Let me try improve your hint: - "save_content()" method doesn't get the content, to achieve that you're supposed to use "content()". - I found a strange behaviour: it looks like Mechanize doesn't like ';jsessionid' into FORM action URIs. Thanks! Marco
Direct Responses: 3274 | Write a response
Posted on Tue Oct 17 18:15:28 2006 by gdakram in response to 3272
Re: Dinamically setting form action
Glad it worked out for you. Sorry about the save_content() glitch. Guess I have been using that method a little too much nowadays to debug my code :). Anyways, I haven't had any problem with session based server interactions using Mechanize, I would be interested in taking a look at it. It would be nice to learn some new workarounds.
Write a response