开发者

Passing php form info to javascript form

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>
<in开发者_Python百科put 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.


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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜