PHP Classes

forms with no name

Recommend this page to a friend!

      Browser  >  All threads  >  forms with no name  >  (Un) Subscribe thread alerts  
Subject:forms with no name
Summary:how would I select a form with no name
Messages:4
Author:Orion Tiller
Date:2009-06-30 02:15:11
Update:2009-06-30 15:50:36
 

  1. forms with no name   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2009-06-30 02:15:11
I have a form on a webpage that I would like to submit with this class but how can I specify to submit this form if there is no name.

Thanks


//Form code

<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
<script type="text/javascript" src="http://i2.slickdeals.net/clientscript/vbulletin_md5.js?v=364"></script>
<table border="0" cellpadding="0" cellspacing="3">
<tbody><tr>
<td class="smallfont"><label for="navbar_username">User Name</label></td>
<td><input class="bginput" style="font-size: 11px;" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" type="text"></td>
<td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" checked="checked" type="checkbox">Remember Me?</label></td>

</tr>
<tr>
<td class="smallfont"><label for="navbar_password">Password</label></td>
<td><input class="bginput" style="font-size: 11px;" name="vb_login_password" id="navbar_password" size="10" tabindex="102" type="password"></td>
<td><input class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" type="submit"></td>
</tr>
</tbody></table>
<input name="s" value="" type="hidden">

<input name="do" value="login" type="hidden">
<input name="vb_login_md5password" type="hidden">
<input name="vb_login_md5password_utf" type="hidden">
</form>



//php code.
$b -> submitForm (
$b -> getForm ( "//form[@id='']" ) //what to put here?
-> setAttributeByName ( 'vb_login_username', 'myusername' )
-> setAttributeByName ( 'vb_login_password', 'mypassword' )
-> setAttributeByName ( 'cookieuser', 'unchecked' ),
'fulltext'
)

  2. Re: forms with no name   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2009-06-30 02:59:21 - In reply to message 1 from Orion Tiller
I figured it out. This worked nicely.
$b -> getForm ( "//form[2]" )

  3. Re: forms with no name   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2009-06-30 07:28:39 - In reply to message 1 from Orion Tiller
How can I click a link on a page that has 2 of the same

$b -> click ( "New Thread" )
// Don't know what to use to get just one of them then. could I use /div/li/a[n] where n is the nth link that fits that nesting? or is there a simpler way to use either one of the "New Thread" links?


PHP Fatal error: Uncaught exception 'Exception' with message '2 links found matching: New Thread' in /var/www/sharedip/browser.class.php:103\nStack trace:\n#0 /var/www/sharedip/browser.test.php(32): Browser->click('New Thread')\n#1 {main}\n thrown in /var/www/sharedip/browser.class.php on line 103


This is the link I need to be clicked I am not having much luck trying
<li class="forumbuttonli"><a class="forumbutton" href="newthread.php?do=newthread&amp;f=9" rel="nofollow"><span><img title="Post New Thread" src="http://i2.slickdeals.net/images/slickdeals/blank.gif" class="concat-general newtopic-trans" alt="Post New Thread" border="0">New Thread</span></a></li>


Thanks

  4. Re: forms with no name   Reply   Report abuse  
Picture of Jon Gjengset Jon Gjengset - 2009-06-30 15:50:36 - In reply to message 3 from Orion Tiller
The function supports XPath, so it would be wise to read up a bit on that..
Maybe something like this will help:
//a[text() = 'New Thread'][1]