Link to home
Create AccountLog in
Avatar of PatrickAdrichem
PatrickAdrichem

asked on

JavaScript and PHP Onclick ask for information (prompt) and process

Alright i have this list of e-mail adresses and this button to change them,
usually i load a new page using the id of the adress and fill in the information and have them use
a form to edit the adress etc.

In this case, i only want to edit the adres, nothing else, just 1 box. So i was hoping i could do it with javascript.
something like:

<a href='javascript:onClick=window.prompt("New e-mail adres:", "<?php echo($row[1]); ?>")'>edit</a>

Only now i have to get it to forward the information to "adresses.php?id=<?php echo($row[0]); ?>"

Is this even possible with this simple javascript?
ASKER CERTIFIED SOLUTION
Avatar of flasht
flasht

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of PatrickAdrichem
PatrickAdrichem

ASKER

But how do i make this work in the onclick event? adding the ID of the DB entry? and requesting for the new adres, because a while mysql_fetch_row statement is making the adress list
I've done this:

<head>
      <script type="text/javaScript">
            function change_adress(adres_id, old_adres) {
                  alert("boo");
                  advAJAX.get({
                        url: "adressen_more.php",
                        parameters : {
                          "var1" : adres_id,
                          "var2" : window.prompt("Nieuw email adres:", old_adres)
                        },
                        onSuccess : function(obj) { alert(obj.responseText); },
                        onError : function(obj) { alert("Error: " + obj.status); },
                  });
            }
      </script>
</head>

<body>
    <td width=300><center><font style='font-family: verdana; font-size: 9pt; color: black;'><a class='menu' href="javascript:onclick(change_adres('<?php echo($row[0]); ?>','<?php echo($row[1]); ?>'))">wijzig</a></font></center></td>
</body>

but it doesn't work
also tried href="#" onclick="change_adres('<?php echo($row[0]); ?>','<?php echo($row[1]); ?>')"

which does not give any errors on the page eather, but the click does nothing! =S
Never mind i fixed it myself like this:

            function change_adres(ourid,email) {
                  document.hiddenform.idfield.value = ourid;
                  document.hiddenform.mailfield.value = window.prompt("Nieuw e-mail adres:", email);
                  document.hiddenform.submit();
            }
I'm glad I could help ;-)