0

I have this function onEdit() and now I want to send the value of variable id to a php file (let's call it test.php) so that using that value I can auto fill the popup called modtemplate which is located in test.php file.

Is there any way to accomplish this?

Any help on this will be greatly appreciated!

function onEdit() {
    var checkboxs = document.getElementsByTagName("input");

    var id='';
    for (var b=0; b<checkboxs.length; b++) {
        if( (checkboxs[b].type == "checkbox") && (checkboxs[b].checked) )  {
            id = checkboxs[b].value;
                    break;
            }
    }

    if(!id)
        alert("Please select a record to edit");
    else    
        document.getElementById('modtemplate').style.visibility = 'visible';

}
1
  • Send an AJAX request? standard form POST? Hard to tell what you are asking Commented May 27, 2011 at 18:48

2 Answers 2

5

You need some AJAX, sir.

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

Comments

1

You can either use ajax to send the record and then use the response. or you can pass the value in the url like so

if(id) {
     window.location.href = "test.php?id="+id;
}

and in the server side u can retrive this value using the $_GET variable

$id = $_GET['id'];

For ajax it is a good idea to use jquery as it takes all the hard work out of the way

2 Comments

** It takes all the learning out of the way. Thats all. You should learn how to use AJAX properly, not just skip to a third-party framework.
@Greg Agnew: learning ajax is absolutely a good idea. But jquery is already there, and it does such a wonderful job. why not use it?

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.