DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    russ tomendal Guest

    dynamically change an HTML FORMs "action=" property


    Hi,

    I'm trying to dynamically change the URL in the "action=" property on a single
    HTML FORM. I have 1 form with 3 option buttons (which may become 1 drop down
    box). The form needs to be submitted to a different URL depending on which
    option the user chooses. My DHTML book say it can be done, but doesn't show
    how. Any suggestions? Thanks in advance.

  2. #2
    Michael D Guest

    Re: dynamically change an HTML FORMs "action=" property

    Create client side script (javascript) to do this. An example would be as
    follows:
    ----------------------------------------------------------------------------
    ------
    function GetAction () {

    document.frmFile.Action = document.all.cboValues.text

    }



    function Submit () {

    document.frmFile.submit();

    }

    ----------------------------------------------------------------------------
    ------------

    The name of the form you would create in your HTML tag <form> would be
    "frmFile" in this example.

    ex. <form Method=Post Target=Some_frame id=frmFile Name=frmFile>

    Likewise, the name of the cbobox where you're action values reside would be
    "cboValues" in this example.

    So all you'd have to do would be to set the action value upon click event or
    there about.

    ex. <SELECT id=cboDocType name=cboDocType onclick=GetAction(); >

    The click event may, or may not be, the desire event you want, but it'll get
    you there.


    When ready to submit, you can do that via javascript as well (ie Submit
    shown above).


    Good luck

    Michael





    russ tomendal wrote in message <38d3b00a@news.devx.com>...
    >
    >Hi,
    >
    >I'm trying to dynamically change the URL in the "action=" property on a

    single
    >HTML FORM. I have 1 form with 3 option buttons (which may become 1 drop

    down
    >box). The form needs to be submitted to a different URL depending on which
    >option the user chooses. My DHTML book say it can be done, but doesn't show
    >how. Any suggestions? Thanks in advance.




  3. #3
    russ tomendal Guest

    Re: dynamically change an HTML FORMs "action=" property


    Thanks very much. That's what I needed.

    "Michael D" <mdurkin@intertech.com> wrote:
    >Create client side script (javascript) to do this. An example would be

    as
    >follows:
    >----------------------------------------------------------------------------
    >------
    > function GetAction () {
    >
    > document.frmFile.Action = document.all.cboValues.text
    >
    > }
    >
    >
    >
    > function Submit () {
    >
    > document.frmFile.submit();
    >
    > }
    >
    >----------------------------------------------------------------------------
    >------------
    >
    >The name of the form you would create in your HTML tag <form> would be
    >"frmFile" in this example.
    >
    > ex. <form Method=Post Target=Some_frame id=frmFile Name=frmFile>
    >
    >Likewise, the name of the cbobox where you're action values reside would

    be
    >"cboValues" in this example.
    >
    >So all you'd have to do would be to set the action value upon click event

    or
    >there about.
    >
    > ex. <SELECT id=cboDocType name=cboDocType onclick=GetAction();
    >
    >
    >The click event may, or may not be, the desire event you want, but it'll

    get
    >you there.
    >
    >
    >When ready to submit, you can do that via javascript as well (ie Submit
    >shown above).
    >
    >
    >Good luck
    >
    >Michael
    >
    >
    >
    >
    >
    >russ tomendal wrote in message <38d3b00a@news.devx.com>...
    >>
    >>Hi,
    >>
    >>I'm trying to dynamically change the URL in the "action=" property on a

    >single
    >>HTML FORM. I have 1 form with 3 option buttons (which may become 1 drop

    >down
    >>box). The form needs to be submitted to a different URL depending on which
    >>option the user chooses. My DHTML book say it can be done, but doesn't

    show
    >>how. Any suggestions? Thanks in advance.

    >
    >



  4. #4
    Savant Guest

    Re: dynamically change an HTML FORMs "action=" property


    Hi,
    That's very simple.
    Just use the following script
    document.form.action="URLNAME";
    Do it in appropriate event.
    Regards

    "russ tomendal" <rusjenandall@netzero.net> wrote:
    >
    >Hi,
    >
    >I'm trying to dynamically change the URL in the "action=" property on a

    single
    >HTML FORM. I have 1 form with 3 option buttons (which may become 1 drop

    down
    >box). The form needs to be submitted to a different URL depending on which
    >option the user chooses. My DHTML book say it can be done, but doesn't show
    >how. Any suggestions? Thanks in advance.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links