PDA

View Full Version : Working Multiple TLD Queries



tydoehk
05-26-08, 02:02 AM
So I read through the forums a bit and did not see a way to use check boxes instead of a drop down list when checking for domains from the home page for example (outside of whmcs).

So I put one together, and it seems to work rather well so far. I just gather the values of the checkboxes in javascript and build the bulkdomains field (used in the bulk check option) value adding the new line chars between each. Then send the form off the the domainchecker.php page.

So the onsubmit would return this function call:

If this was already posted somewhere, I apologize for not having found it.

(this code is poc only btw)


function makedq() {
var fdomain = document.getElementById("domain");
var fcom = document.getElementById("com");
var fnet = document.getElementById("net");
var forg = document.getElementById("org");
var fbulk = document.getElementById("bulkdomains");
var dq_arr = new Array();
var dq = "";
var tldcheck = 0;

if(fdomain.value.length > 2) {
// build bulk
if(fcom.checked) {
dq_arr.push(fdomain.value + "." + fcom.value);
++tldcheck;
}
if(fnet.checked) {
dq_arr.push(fdomain.value + "." + fnet.value);
++tldcheck;
}
if(forg.checked) {
dq_arr.push(fdomain.value + "." + forg.value);
++tldcheck;
}
// assemble bulk
for(var r=0; r < dq_arr.length; ++r) {
dq += dq_arr[r];
if(dq_arr[r+1]) {
// add new line
dq += "%0D%0A";
}
}
if(tldcheck > 0) {
fbulk.value = unescape(dq);
/* disable uneeded fields
fdomain.disabled = true;
fcom.disabled = true;
fnet.disabled = true;
forg.disabled = true;*/

return true;
} else {
return false;
}
} else {
return false;
}
}

chickendippers
05-26-08, 08:50 AM
The code is in Utilities > Integration Code.

tydoehk
05-26-08, 12:50 PM
Actually no, the code in "integration code" is for a select field NOT a group of checkboxes.

Matt
05-26-08, 01:02 PM
Why don't you just use a simple form with regular checkboxes for the TLD selections?

Matt

chickendippers
05-26-08, 01:57 PM
My apologies tydoehk, I misread your post.

tydoehk
05-26-08, 11:49 PM
Why don't you just use a simple form with regular checkboxes for the TLD selections?

Matt

Thats what I did, but in order to pass in a check for something like:

mydomain .com, .net and .org you have to send to the bulk check form. Otherwise you can only check one tld per query.

juiced
07-07-08, 01:20 PM
Could you post your form code here aswell? (whole page would be awesome) Cheers

tydoehk
07-07-08, 01:36 PM
I just collect the checked values and pass them to the bulk checker. The form calls some JS that takes care of that. Nothing spectacular, and Im sure theres a cleaner way to do it, but:


function makedq() {
var fdomain = document.getElementById("domain");
var fcom = document.getElementById("com");
var fnet = document.getElementById("net");
var forg = document.getElementById("org");
var fbulk = document.getElementById("bulkdomains");
var dq_arr = new Array();
var dq = "";
var tldcheck = 0;

if(fdomain.value.length > 2) {
// build bulk
if(fcom.checked) {
dq_arr.push(fdomain.value + "." + fcom.value);
++tldcheck;
}
if(fnet.checked) {
dq_arr.push(fdomain.value + "." + fnet.value);
++tldcheck;
}
if(forg.checked) {
dq_arr.push(fdomain.value + "." + forg.value);
++tldcheck;
}
// assemble bulk
for(var r=0; r < dq_arr.length; ++r) {
dq += dq_arr[r];
if(dq_arr[r+1]) {
// add new line
dq += "%0D%0A";
}
}
if(tldcheck > 0) {
fbulk.value = unescape(dq);
/* disable uneeded fields */
fdomain.disabled = true;
fcom.disabled = true;
fnet.disabled = true;
forg.disabled = true;

return true;
} else {
return false;
}
} else {
return false;
}
}

and the form is something like:


<form method="post" action="/clients/domainchecker.php" name="dnsform" id="dnsform" onsubmit="return makedq();">
<input name="domain" id="domain" value="" size="40" type="text" class="tldtext">
<div class="tldgrp"><input name="com" id="com" value="com" type="checkbox" class="tldcb" /><span class="tld">COM</span></div>
<div class="tldgrp"><input name="net" id="net" value="net" type="checkbox" class="tldcb" /><span class="tld">NET</span></div>
<div class="tldgrp"><input name="org" id="org" value="org" type="checkbox" class="tldcb" /><span class="tld">ORG</span></div>
<input type="hidden" name="bulkdomains" id="bulkdomains" value="" />
<input type="hidden" name="search" value="bulk">
</form>

I hope that helps you out or gets you headed in the direction you need.