SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to change "value" attribute AFTER submit button is pressed?

    I have the following input tags that create two buttons with the labels of "Save" and "Preview". When either button is pressed the same form is submitted and the "action" variable will have the appropriate value depending on which button was pressed.

    Code:
    <input type="submit" name="action" value="Save" style="width:150px;">
    <input type="submit" name="action" value="Preview" style="width:150px;">
    My problem is that I need to dynamically (using javascript) change the value of the action take AFTER the button is pressed.

    Basically, the button label needs to stay as they are but the value of the action variable needs to be something different. (I am unable to change the script..)

    Can anyone show me how this can be done? I suspect some javascript on the onClick event would do it..

    Thanks!

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <input type="submit" name="action" value="Save" onClick="this.form.action='somepage.asp'">

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by jofa
    <input type="submit" name="action" value="Save" onClick="this.form.action='somepage.asp'">
    Thanks, but I'm trying to only change the value of the action variable for the input tag.. not the entire form. Both buttons need to be submitted to the same form.. and it is only the action value of the buttons itself that I need to change.

    Thanks!

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like this?

    <input type="submit" name="action" value="Save" onClick="this.value='Something else';">


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
  •