3.0 beta 2

Submitting A Form Value For $_POST

I've worked out how to submit a form from a button with the following code: -

obj.onControlClicked = function(){
document.formname.submit();
}

But how do I submit the value for $_POST or $_GET?

in HTML you would do the following: -

<input type='submit' name='Open' Value='Open'>

Help!!
Jez
March 13,
You'd need to specify the action. i.e.
document.formname.action = some_value
Anthony
March 13,
Thanks for that, it worked a treat!

I suspect they're is a much easier/efficiently way to post back to the form, but I have used the following code: -

In my example I want to post 'Next' (which will be used for a button to get the next record from my dataset) back to the form.

obj.onControlClicked = function(){
document.Customer.action="http://localhost/customer.php"+page+"&Next=Next";
document.Customer.submit();
}

This submits the form adding the &Next=Next into the HTTP tag and then using $_GET['Next'] I can filter the form appropriately.

The next problem I have is, AW are using the HTML <Span> tag to display the button in the form and it appears that you can only display the button on the form once! My form is tabbed and the functions (buttons) sit nicely at the top. When I click onto the next tab the buttons disappear!

Hey it's all a challenge! :)
Jez
March 15,
Hello Jez, yes, there is an easier way.

Firstly, I'm not sure if you're using the word form correctly. You mention get and post operations but they way you describe a form, it seems more like a page form rather than an HTML FORM tag.

With the HTML FORM tag, you would do a submit. Basically, this just saves you the trouble of fashioning the HTTP request string yourself. It appends all the form's object values to the request string for you. So your example above isn't quite correct.

However, you can dispense with a form and do the whole operation yourself. For example, I did this recently with a grid and some buttons which did actions from the grid -
function        buttoncallback()
        {
            var val = obj1.getSelectedRows()

            if (val.length != 1)
                alert("Please select a row")
            else
            {
                var foo = devdata[val]
                window.location.assign("/cgi-bin/graph?CSERVER="
                    + foo[1].replace(/\s+$/,"") + "&DEVICE=" + foo[2])
            }
        }

So you can use window.location.assign (or its variants) to load a new window without creating a form to do it. This matches what your example does.

However, from what you are describing, it seems you might actually want to use AJAX methods to change some details on an existing page. Have a look at this -
/aw.http.request/

Also, you might want to check your use of localhost.

Regarding your last problem, I'm not entirely sure I understand what you're describing. Practically all the AW objects are built using spans. The tabs use divs, however. Are you saying your buttons appear on the first tab's div or on the main encompassing div?

You could try placing your buttons outside the divs. But would depend on what you're doing. Try starting a new thread here /ui.tabs/ and post some code to illustrate your problem better.

Note that the Firebug plugin debugger for FireFox is very handy for working out what's going on with more complicated objects like tabs.
Anthony
March 16,
Hi Anthony,

Thanks for your advice, I have only been writting my web application since Jan 09 so please bear with me if I get some of the words and phrases incorrect.

Your example would work, but because of the problem I face with the buttons not displaying on more than one tab, which is down to the DIVS, I have found another solution and created my buttons using submit buttons and changing the look using CSS and GIF's.

Thanks once again for your advice and time! :)
Jez
April 4,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.