Page 1 of 1

Accessing form data

PostPosted: Wed Dec 23, 2009 6:21 pm
by gsilvis
Can I access the data keyed into a form on the edit page?

In the Edit page I want to add a clickable link after a field (using the function block__after_%field%_widget()) that will send the user to another website to look up information about what he has entered into the field. That html needs what he has keyed in. He hasn't saved yet so its not in the database.

Can I access the data that has just been typed in?

Thanks
George

PostPosted: Thu Dec 24, 2009 11:37 am
by shannah
Yes. You can you javascript.

In general:
Code: Select all
<script type="text/javascript">
function gotoPage(){
   var fieldVal = document.getElementById('my_field').value;
   window.location.href='http://example.com/index.php?param1='+fieldVal;
   return false;
}
</script>
<a href="javascript:gotoPage();">Click here</a>

Re: Accessing form data

PostPosted: Thu Dec 24, 2009 2:34 pm
by gsilvis
Very cool

I changed to window.open to send my query to another window.

And I took the "return false" from the script function so that when I collapsed the window I was sent to I don't just see the word "false", but my edit window with the users input still in place.

Thanks!
George