0

I'm really struck here. I have a form Ii want to submit it and get value on other form in Jquery:

<form id="rentals_form" name="popup_form" action="rentals.php" method="POST">
    <input alt="" style="display:none;" id="copy_id" name="copy_id" type="text">
</form>

<button 
    class="save_button" 
    value="copy_listing_button" 
    onclick="document.forms[$('#copy_listing option:selected').val()+'_form'].submit();" 
    style="font-size:11px; padding:0 3px 0 3px;">
        Go
</button>

now I need to get the value on other page rentals.php:

$(document).ready(function() 
{
    // here I want to get copy_id value.please note this is jquery so i want to get in jquery
});
  • 2
    Javascript variables don't persist across different pages. If you need to save data, use cookies or LocalStorage. – Barmar Apr 19 '13 at 19:24
  • copy_id is control not js variable...i want to get this control value –  Apr 19 '13 at 19:25
  • You've completely rewritten the question. The question I was commenting on was about a variable being set during a button click. – Barmar Apr 19 '13 at 19:27
  • Yes i made it clear now,please read it –  Apr 19 '13 at 19:28
  • You can use ajax call and in that call you can define your URL where it needs to be redirected and you can get the variable like $_post['var1'] or you can also redirect page with rentals.php?Copy_id= 1 and get that variable on second page! or you can use session variable if you dont want user to see the copy_id value in URL – rach Apr 19 '13 at 19:33

2 Answers2

0

when you press any of the buttons a,b or c in menu.html, you said it loads index.html. So once the index.html is loaded in browser, there's no history of any of the buttons from previous page in current dom.

what you need to do is submit information from menu.html which can then be used up in index.html.. see form submissions, or at least request parameters.

you can access request parameters in javascript on index.html using "window.location" and searching for the string.

EDIT: I see you updated the question. See other answer posted below regarding using php to access the request param.

coolpal
  • 31
  • 3
0

Please refer to following link. It may help you to achieve your goal. PHP Pass variable to next page

$(document).ready(function() {
    $('#button_ID').live('click',function(e){
        e.preventDefault();
        var currentId = $(this).attr('id'); 
        var form_id = $('#'+currentId).closest('form').attr('id');
        var copy_id = $("#"+form_id+" input[name=copy_id]").val();

        $.post('rentals.php', { copy_id : copy_id }, function (data) {  
            alert(data);
        }, 'json'); 
        return false;
    });
});

on rentals.php get value of copy_is using $_POST['copy_id '];

Community
  • 1
  • 1
rach
  • 669
  • 2
  • 8
  • 31
  • i mentioned clear that i do not want to get in php...i want to get in jquery there in rentals.php...there is a jquery function where i want to use it –  Apr 19 '13 at 19:46