Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

form action paramenters in realtime

  • 19-06-2006 3:01pm
    #1
    Closed Accounts Posts: 8,478 ✭✭✭


    Wondering can I do something like the following
    <form action="whatever.php?test=+document.textfield.value+" method="post">
    

    I support I'm trying to escape the "'s in the action tag somehow. Which I doubt can be done.

    Just wondering....


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Not entirely sure what you're getting at, but have you tried
    document.write('<form action="whatever.php?test=' + document.textfield.value + '" method="post">');
    
    ?

    The problem here is that if javascript is disabled, the form will 100% fail to function. For dynamic form actions I would advise server-side scripts instead of client-side.


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    seamus wrote:
    Not entirely sure what you're getting at, but have you tried
    document.write('<form action="whatever.php?test=' + document.textfield.value + '" method="post">');
    
    ?

    The problem here is that if javascript is disabled, the form will 100% fail to function. For dynamic form actions I would advise server-side scripts instead of client-side.

    Yes I thought of document.write, but wouldn't suit what I was at (cos I was already using php echos in the form action parameters).

    No biggie - just curios.

    Thanks Mr Seagull.


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    Wondering can I do something like the following
    <form action="whatever.php?test=+document.textfield.value+" method="post">
    

    I support I'm trying to escape the "'s in the action tag somehow. Which I doubt can be done.

    Just wondering....
    <form name="theForm" action="whatever.php" method="post">
    <input type="text" name="test"/>
    </input>
    

    Or, different again.
    <form name="theForm" method="post">
    </form>
    <input type="text" onkeyup="document.forms.theForm.action='whatever.php?test='+this.value"/>
    

    I think


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    akari I like your 2nd idea, but how would you implement that for mulitple form fields? Your 1st method is the standard method alright. I'm thinking logo_homepage.gif


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    LOL.

    Well, using akari's second idea, you could expand it so that the onChange handler for all the fields calls a function which queries the value of each field and rebuilds the query string.


  • Advertisement
  • Closed Accounts Posts: 169 ✭✭akari no ryu


    akari I like your 2nd idea, but how would you implement that for mulitple form fields? Your 1st method is the standard method alright. I'm thinking logo_homepage.gif
    Each input has an onkeyup trigger handler for it.
    No problem really.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Just wondering why you would need to do something like this?
    Why are you using post when its more a get method? I might be totally reading this wrong, if so sorry.


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Webmonkey wrote:
    Just wondering why you would need to do something like this?

    Why not? Handy to have these other methods of doing the same thing.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    I suppose yeah. I needed to do somethign similer but it was:

    parent.location="'something.php'+document.form1.textfield.value+'&value=2242'";

    i suppose it is a bit similer


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    One common reason for doing it is for validating entries in the form with server side code as they're entered. You could hard code the form to submit back to it's own page, and have the onChange triggers of your fields submit the form. Then in that page have the logic to validate any entries against a database. Then in the onClick trigger of your submit button, change the action of the form to submit to whatever page is going to process the form.


    so what's this AJAX thing people are always on about ;)


  • Advertisement
  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    stevenmu wrote:
    so what's this AJAX thing people are always on about ;)

    I hear it makes for an excellent laundry detergent

    101849_front200.jpg


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    I hear it makes for an excellent laundry detergent

    101849_front200.jpg
    haha!
    I'm actually going to order the, PHP & MySQL: Building Responsive with Ajax.
    Anyone know if it is any good?


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I hear it makes for an excellent laundry detergent

    101849_front200.jpg
    :)


Advertisement