0

I need a JavaScript solutions. I recived data from aweber after user subscribe, in success page. so url like:

http://example.com/success/[email protected]&name=Jhon&custom_phone=0005551114&custom_location=USA

They give some javascript solutions to show data in webpage or success page...

Referance: https://help.aweber.com/entries/21696333-How-Do-I-Display-Subscribers-Names-or-Email-Addresses-On-My-Thank-You-Page-

So When I put

<script type="text/javascript">formData.display("name")</script>
<script type="text/javascript">formData.display("email")</script>
<script type="text/javascript">formData.display("custom_phone")</script>
<script type="text/javascript">formData.display("custom_location")</script>

value will show in my page. But How can I put the value in a input field in success page??

<form action="" method="post">
<input type="text" name="username" value="Jhon">
<input type="text" name="useremail" value="[email protected]">
<input type="text" name="phoneno" value="0005551114">
<input type="text" name="country" value="USA">
<input tyoe="submit" value="Submit">
</form>

Please help..

1 Answer 1

1

You can change the Javascript code a bit, like this:

<script type="text/javascript">
 var formData = function() {  var query_string = (location.search) ? ((location.search.indexOf('#') != -1) ? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : '';  
var elements = [];  
if(query_string) {     
    var pairs = query_string.split("&");     
    for(i in pairs) {     
        if (typeof pairs[i] == 'string') {           
            var tmp = pairs[i].split("=");           
            var queryKey = unescape(tmp[0]);           
            queryKey = (queryKey.charAt(0) == 'c') ? queryKey.replace(/\s/g, "_") : queryKey;   
            elements[queryKey] = unescape(tmp[1]);      
             }    
       } 
 }  
return {     
    display: function(key) {         
        if(elements[key]) {           
             document.write('<input type="text" name="' + key + '" value ="' + elements[key] + '"');         
         } 
         else {         
               document.write("<!--If desired, replace everything between these quotes with a default in case there is no data in the query string.-->");          
          }     
  }   
} 
}
(); </script>

And your HTML will look like this:

<form action="" method="post">
<script type="text/javascript">formData.display("name")</script>
<script type="text/javascript">formData.display("email")</script>
<script type="text/javascript">formData.display("custom_phone")</script>
<script type="text/javascript">formData.display("custom_location")</script>
<input tyoe="submit" value="Submit">
</form>
Sign up to request clarification or add additional context in comments.

2 Comments

Yahoo!!!! You are a genius man :).. You are really a live saver :) .. I love you :)
Alex, your solutions is work.. see here: tiny.cc/customfrom ... I use integrate it with wordpress contact from 7 .. now when I click send button, I got email with details.. but page redirect in 404 page.. any solutions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.