EDIT: A few months later I attempted this again using the same syntax I had tried the first time (posted below). For some reason, it worked! Maybe something other than my syntax was causing the ineffectiveness... END EDIT
I've been searching forums for a couple of hours now trying to find a solution to this problem, but none of the things I've tried work.
I'm using VBA to automate the process of creating a survey on SurveyMonkey. So far I've been able to:
Log into my account,
Click several hyperlinks to create a new response collector,
Name the collector,
Go to the collector settings,
And, select three of four radio buttons to change collector settings.
The issue isn't that I can't select the radio buttons; my code selects the first three buttons just fine. What puzzles me is that the fourth button doesn't change! I use the same process for each button, so I can't figure out why the last button won't select.
Here's the section of my code:
objIE.Document.getElementById("rdlResponseType_1").Click 'Allow multiple responses = Yes
objIE.Document.getElementById("rdlResponseEdit_1").Click 'Allow Responses to be Edited = Yes
objIE.Document.getElementById("rdlThankyou_1").Click 'Display a "Thank You" page? = Yes
objIE.Document.getElementById("rdlCompleteOpt_1").Click 'Survey Completion = Close Window
This is the HTML for the radio buttons:
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
<tr id="CompleteOptDesc">
<td style=""> </td>
<td>After the respondent leaves the survey:</td>
</tr>
<tr id="CompleteOptItems">
<td style=""> </td>
<td align="left" nowrap="nowrap" valign="top">
<table id="rdlCompleteOpt" class="Clean radioList" OnClick="radioToggle('rdlCompleteOpt', '0', 'panLink');" name="rdlCompleteOpt" border="0" style="white-space: nowrap">
<tr>
<td><span style="white-space: nowrap"><input id="rdlCompleteOpt_0" type="radio" name="rdlCompleteOpt" value="0" checked="checked" /><label for="rdlCompleteOpt_0"><b>Redirect</b> to your own webpage.</label></span></td>
</tr><tr>
<td><input id="rdlCompleteOpt_1" type="radio" name="rdlCompleteOpt" value="2" /><label for="rdlCompleteOpt_1"><b>Close Window</b></label></td>
</tr>
</table>
Here is the code for the toggle section of the radio:
<td width="65%" valign="top">
<div id="panLink" style="DISPLAY:inline">
<div class="URLinfo">
<b>Enter a URL</b> to jump to upon leaving the survey:<br />
<div title="REQUIRED: Enter URL (255 character max)" style="padding:4px 0 2px 0;">
<input name="txtWebLink" type="text" value="http://www.surveymonkey.com/" maxlength="255" size="40" id="txtWebLink" class="RQR opaque" />
</div>
<span class="tip">Example: <u>http://www.mysite.com/home.html</u></span>
</div>
</div>
</td>
Any suggestions would be very appreciated!
There's a couple things to consider:
When are you calling this code? OnNavigate or DocumentComplete? It may be that the object doesn't exist yet. You can check to see if it does by using a breakpoint and adding a watch for the expressions
objIE.Document.getElementById("rdlCompleteOpt_1")
Use OnDocumentComplete to ensure the HTML components exist
It's possible the way you are calling the click function is causing an issue. Try this
Call objIE.Document.getElementById("rdlCompleteOpt_1").Click()
I doubt that it is likely to have much impact but I like to verify everything.
Isolate the cause of the issue by removing the 'layers'. Can you accomplish this using pure JavaScript that's invoked from the IE dev tools (F12) JavaScript console?
If no then the issue is with how you're interacting with the page elements. If yes then we need to figure out what it is with the VBA intaction is causing an issue. Again see #2 as it is likely the cause of the issue.
Also, does the issue occur if you change the HTML order of the elements? What if you call it this way?
objIE.Document.getElementById("rdlCompleteOpt_1").Click 'Survey Completion = Close Window
objIE.Document.getElementById("rdlResponseType_1").Click 'Allow multiple responses = Yes
objIE.Document.getElementById("rdlResponseEdit_1").Click 'Allow Responses to be Edited = Yes
objIE.Document.getElementById("rdlThankyou_1").Click 'Display a "Thank You" page? = Yes
Does it work then or does the "last" item fail?
Highly unlikely to be the cause but the HTML supplies is missing the code to close cell, row and table.
</tr>
</table>
<!-- missing -->
</td>
</tr>
</table>
While not the specific answer to your question I believe this may be inline with the intent of your post. Since you want to manage a surveymonkey collector take a look at the SurveyMonkey API here as using an API gives you quite a few benefits.
you don't have to rely on user elements which may change or be changed outside of your control
you can use a controlled and "contracted" interface to manage the information which covers you for any future changes (assuming they don't deprecate and stop supporting the API)
Related
I have
<td id="Id1">Text</td>
<td id="Id2"><input type="text" value="Text" /></td>
I want that style of 2 td will be same like td1.
I tried style="border:none;", but i had text area editing or else. I just want from td2 value, but it doesn't correspond in design.
With td2 I have table cell, it can be edited. I want to have constant text showed to user, I want it not to be changed
It would be helpful if you share resources related to your issue like css code and behavior image. Anyways, this code has "=" misplaced in first line.
**<td id="Id1">Text</td>**
<td id="Id2"><input type="text" value="Text" /></td>
To make the design same, you can attach same styling classes to all the rows
You can refer this for more on tables styling, it has some good options
https://www.w3schools.com/css/css_table.asp
I'm working on some email that will be deployed via Exact Target. We have a lot of AMPScript dictating what is going on within the email(s). The content blocks of the email are dynamically filled, and when a field is left empty there is still a call made to that table section, which then inserts a blank space on the email. Thus throwing the design out of whack.
My question is, is there anyway I can have those empty cells completely removed from the page when not in use?
here is the code sample ...
Set #SendLog_blockC1 = lookup("RaceDataSendLog","BLK_C1","SubID",#SubLookup,"JobID",#JobLookup,"BatchID",#BatchLookup)
...
...
...
Set #blockC1 = Concat("My Contents\Newsletter\",#SendLog_blockC1)
....
....
....
....
%%[IF empty(#blockC1) THEN]%%
%%[ELSE]%%
<tr>
<td align="left" valign="top" >
%%=ContentAreaByName(#blockC1,"",0)=%%
</td>
</tr>
%%[ENDIF]%%
Thank you in advance.
On the assumption you're referring to that space above your ELSE - this should work:
<!--%%[
IF empty(#blockC1) THEN
ELSE]%%-->
<tr>
<td align="left" valign="top" >
%%=ContentAreaByName(#blockC1,"",0)=%%
</td>
</tr>
<!--%%[ENDIF]%%-->
This will hide the AMPscript in the HTML, in addition - you don't really need the IF to produce the space, you can just have the ELSE right after it.
and thank you for your responses. I was finally able to resolve the issue of the extra spacing.
What I did was remove the <tr> and <td> tags from around the if/else statements. I then placed those <tr> and <td> tags around the content blocks that are brought in by the PM's when they decide which blocks to use. This solved the problem of the extra spacing. Client is happy!!!
Thanks again guys!!!
I have a weird situation happening at the moment, been using datatables library for a while and suddenly i discovered that if i have an input with certain value, if i move to another link and then return using the browser back button, the first input value gets empty.
Altough if i inspect the element i can see the value right there in the source code, but not on the screen, if i go back and forward one more time, the second input goes clear, and so on...
I have tested this behavior on multiple browsers and so far, only those based on Chromium (Google Chrome and Opera) seems to be doing this.
Here is an example of my markup
<table class="dataTable">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="My Text" id="myinput" name="myinput" /></td>
</tr>
</tbody>
</table>
I found this option while searching the dataTables documentation:
"bStateSave": true,
But it seems to do nothing.
Ok after posting the question here i noticed something and it solved the problem, not sure why but it's maybe related to the plugin itself.
I didn't had a name attribute within the input tag, and that was the cause, after adding a dynamic name the issue is solved.
Hope it helps someone else who can experience this dumb error. :)
I'm trying to click an anchor element on a web page. I'm using this code:
For each anchor in HTMLDoc.anchors
If anchor.onclick = "validateForm(frmSearchEntry)" Then
anchor.click
exit for
End if
Next anchor
And here is the snippet of html:
<tr>
<td height="35" align="right" nowrap>
<input type="hidden" name="aisposm01formReset" value="">
<img src="/Settlement/static/images/pbs/funcreset.gif" border="0">
<img src="/Settlement/static/images/pbs/funcsearch.gif" border="0" alt=""></td>
</tr>
<tr>
<td valign="bottom" nowrap>
<table>
<tr><td name="txtErrorMessage" class="error"></td></tr>
</table>
</td>
</tr>
However, for some reason when I try to execute the code it just flies right over the for next loop as if there are no anchor elements anywhere on the page. I'm not quite sure what I'm doing wrong here.
Updated to reflect the answer the question noted in the comments
The elements you are trying to find are not actually anchors. See this link for a description of how anchors are implemented in html. An anchor looks like this <a name="anchor"></a> and you would create a link to it like so click here.
Instead, I you could use HTMLDoc.GetElementsByTagName("A") to get all of the links and then iterate through those. Make sure you perform your check based on the .getAttribute function as noted below.
The .OnClick function returns a pointer to the event handling function per msdn. What you probably want instead is .getAttribute(strAttributeName As String, Optional lFlags As Long) (msdn).
Try (UNTESTED):
For each linkelement in HTMLDoc.GetElementsByTagName("a") 'As noted above
If linkelement.getAttribute("OnClick") = "validateForm(frmSearchEntry)" Then
linkelement.click
exit for
End if
Next anchor
If that doesn't work right away, put a breakpoint on the If statement and check the value of anchor.getAttribute("OnClick") in the Watch Window.
Hi all as you can probably tell by my two questions yesterday I'm new to wed development. I really need some help on how to approach the next part of my page. So and advice would be great. I'm not really looking for complete/complex code that I can't understand.. I really just want a point in the right direction so I can then work it out / learn myself. CHEERS :D
Okay so basically I have set up a database user accounts and I want to have a rolling feed of new members... . I want to get the feed to go in the main square, how do I code the feed... For the website so far I have used html and php for coding languages. The server is a mysql server. And tips / pointers would be really helpfull :)
my current code:
<?php
//Account validation
session_start();
if(!(isset($_SESSION['login']))){
header("location:welcome.php");
}
?>
<html>
<body>
<table width ="100%" border="1">
<tr>
<td width="25%">
<h1>TOOB</h1>
</td>
<td>
<!all links and stuff>
</td>
</tr>
<tr>
<td>
<h2>Start exploring the TOOB</h2>
</td>
<td width="75%">
</td>
<td>
<form>
<input type="button" value="Logout" onclick="window.location.href='logout.php'">
</form>
</td>
</tr>
</table>
<br>
<table border="1" align="center" width = "60%" height = "500">
<tr>
<td>
<!--FEED GOES HERE-->
</td>
</tr>
</table>
</body>
</html>
You will need to connect to your mysql database and retrieve your user information. Learn more about PDO, there are plenty of tutorials out there, just google 'php pdo'. When you are done with the connection and the retrieval of your data you will have an array you can loop through and display the rows in your page. For the rolling part, you can use javascript and make an ajax get request every few minutes to refresh the information.
Also please consider using css for creating a layout for your page instead of a table.
Let me know if you need more.
If anyone ever comes across this in future months I have found the solution to what I wanted to do on: http://www.phpsimplicity.com/tips.php?id=1
it teahces you how to limit the results of a mysql function to a certain number of rows. it then moves on to how you can for example output the first ten, then the second group of ten and then the third etc..... I just now have to work out how to put that into a form/display typy thing