Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  104] [ 7]  / answers: 1 / hits: 34257  / 11 Years ago, mon, august 26, 2013, 12:00:00

I am using Buddy.com's API to build a mobile app with a web Interface for Administrators and User Creation. I am still in the initial stages of this project.



The first page I am trying to build is the User Registration page for the website.
This page will have a form asking the users for a username, password, email and some other fields.



I am using the javascript form the page http://buddy.com/developers/#UserAccount_Profile_Create



The function is: function createUserWithName(); And it has some inputs. The function looks like this:



function fixedEncodeURIComponent (str) {  
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
}
function createUserWithName(aName, anEmail)
{
var finalURLStr = https://webservice.buddyplatform.com/Service/v1/BuddyService.ashx;

finalURLStr += ?UserAccount_Profile_Create; // API Call
finalURLStr += &BuddyApplicationName= + fixedEncodeURIComponent(<#Buddy App Name#>);
finalURLStr += &BuddyApplicationPassword= + fixedEncodeURIComponent(<#Buddy App Password#>);
finalURLStr += &NewUserName= + fixedEncodeURIComponent(aName); // The user name
finalURLStr += &UserSuppliedPassword= + fixedEncodeURIComponent(<#password#>); // User password
finalURLStr += &NewUserGender= + male; // male or female
finalURLStr += &UserAge= + 29; // user age (int)
finalURLStr += &NewUserEmail= + fixedEncodeURIComponent(anEmail); // user email
finalURLStr += &StatusID= + -1; // see status table (1-7 or -1)
finalURLStr += &FuzzLocationEnabled= + 1; // true / false: location isn't/is reported accurately
finalURLStr += &CelebModeEnabled= + 0; // true if user is hidden from non-friends
finalURLStr += &ApplicationTag=; // app-related info
finalURLStr += &RESERVED=; // leave empty

$.ajax({ url: finalURLStr })
.done( function(data) {
// Result is a simple string
alert(Result: + data);
})
.fail(function() {
alert(Error while contacting Buddy!);
});
}


I have created a form which asks for the user to input this information.



How can I pass the field data from my form to this function?



This is the code for my form:



<form id=register>

<table width=200 border=0 cellspacing=0 cellpadding=0>
<tr>
<td><label for=username>Username*:</label>
<input type=text id=username name=username />
</td>
</tr>
<tr>
<td><label for=password>Password*:</label>
<input type=text id=password name=password />
</td>
</tr>
<tr>
<td><label for=email>Email*:</label>
<input type=text id=email name=email />
</td>
</tr>
<tr>
<td><label for=gender>Gender*:</label>
<select id=gender>
<option value=null>Please Choose One...</option>
<option value=Male>Male</option>
<option value=Female>Female</option>
</select>
</td>
</tr>
</table>
<input class=button name=submit type=button value=submit onclick=createUserWithName(username.value) />
</form>


Im sure that once someone shows me how to send the username and email to the javascript function I will be able to figure out the rest.



Thank you


More From » html

 Answers
52

first create a function in which you collect all the form data



function getFormData(){ 
var name=document.getElementById('username').value;
var email=document.getElementById('email').value;
/* some other fields */
/* now call ur function by passing the above values */
createUserWithName(name, email);
}


In your form call getFormData() method



<input class=button name=submit type=submit value=submit onclick=getFormData() />

[#76129] Saturday, August 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dequant

Total Points: 88
Total Questions: 99
Total Answers: 95

Location: Ukraine
Member since Sun, Dec 13, 2020
4 Years ago
dequant questions
;