html - Submit form field values to a Javascript function -


i using buddy.com's api build mobile app web interface administrators , user creation. still in initial stages of project.

the first page trying build user registration page website. page have form asking users username, password, email , other fields.

i using javascript form page http://buddy.com/developers/#useraccount_profile_create

the function is: function createuserwithname(); , has inputs. function looks 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);                    // 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 hidden non-friends     finalurlstr += "&applicationtag=";                                                  // app-related info     finalurlstr += "&reserved=";                                                       // leave empty      $.ajax({ url: finalurlstr })         .done( function(data) {             // result simple string             alert("result: " + data);         })         .fail(function() {             alert("error while contacting buddy!");        }); } 

i have created form asks user input information.

how can pass field data form function?

this code 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 once shows me how send username , email javascript function able figure out rest.

thank you

first create function in collect form data

function getformdata(){  var name=document.getelementbyid('username').value; var email=document.getelementbyid('email').value; /* other fields */ /* call ur function passing above values */ createuserwithname(name, email); } 

in form call getformdata() method

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

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -