0

I hope someone can help me. I'm a little at loss on how I can achive this: I'm trying to pass infos generated in my php to another form made in Javascript.
For example, if I put my first name in the input field and click submit, then it would go to another page with the actual form and have the first name already filled there.

One thing that I did notice was that the javascript form isn't within the <form> tag, it's in a bunch of tables with some input fields. I can post what it looks like in pastebin if this can help in understanding what I mean.

Also with this script im unable to edit it, I did not make it, it is one of those script you just place on your site thats auto generated.

My form looks like this:

<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);">

<label for="first">First Name <span class="required">*</span></label>
<input id="first_name" type="text" name="first" applicationforms="true" /><br>
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label>

<span class="fields">Zip <span class="required">*</span></span>
<input id="zip" type="text" name="zip" applicationforms="true" /><br>
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label>

<label for="last">Last Name <span class="required">*</span></label>
<input id="last_name" type="text" name="last" applicationforms="true" /><br>
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label>

<span class="fields">Email <span class="required">*</span></span>
<input id="email" type="text" name="email" applicationforms="true" /><br>
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label>
<input class="button" type="submit" name="send" value="Send" />

</form>

Any help is appreciated; like I said, I'm a bit at loss on what to do with this one.

1
  • That can be more easily done with PHP. Also, your form markup is messed up. <label> shouldn't be used as an error or warning. It should be a label. Commented Oct 5, 2011 at 19:41

2 Answers 2

1

php-form.php

<form action="javascript-form.php" method="post">
  <input type="text" name="name" />
  <input type="submit" value="Submit" />
</form>

javascript-form.php

<form action="" method="">
  <input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" />
  <input type="submit" value="Submit" />
</form>

Use PHP to output the POSTed values in to the value attribute of the form fields. You can also use GET variables and use javascript to parse the window.location and scrape those form values.

Sign up to request clarification or add additional context in comments.

3 Comments

im sorry I should have mentioned that in the javascript form im unable to edit it im just able to place it where I want it to be placed
@NukleHead: "Place it where I want it to be placed" means what? It's an iframe, a script-generated form, ...? You may be able to bind to the original form's submit, then read the form values, and use javascript to "shift" them over to the new form--as long as both forms resides on the same domain.
to be more helpful it looks like this and it generates, its not entirely in a iframe <script type='text/javascript'> var inputOptions = { 'UserID': '#####', 'Product': 'payday', 'ProductTemplate': 'original', 'Server': 'altohost.com' }; document.write('<script type="text/javascript" src="altohost.com/system/applicationforms/init.php?vn=inputOptions"><\/script>'); </script>
0

this seemed to get this done

<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script>
<script>
$(document).everyTime(1000,function(i){
    if($('#ui-datepicker-div').length>0)
    {
        $('#first_name').val('<?php echo $_POST['first_name']; ?>');
        $('#last_name').val('<?php echo $_POST['last']; ?>');
        $('#zip').val('<?php echo $_POST['zip']; ?>');
        $('#email').val('<?php echo $_POST['email']; ?>');
    }
})
$('#first_name').val('test');
</script>

Comments

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.