www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Newbie needs help...

  1. #1
    Join Date
    Aug 2005
    Location
    USA
    Posts
    116

    Newbie needs help...

    How does one go about return a value from a form field and place that value in a hidden input field?

    Code:
    <input type="text" value="$10.00" style="font-weight: bold; bordeR: 0px; width: 100px;font-size: 10pt; color:black; font-family: verdana;" name="cost_total">
    Above is the line of code I want to take the value from. I want to place that value into a hidden field. The value of $10 is the default value, but actual amount changes based on number of items selected.

  2. #2
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    PHP is server-side, so It can't do that kind of thing. The best you can do is use JavaScript:

    Code:
    <input type="text" value="$10.00" ... onchange="a();" />
    <input type="hidden" name="cost_hidden" />
    <script language="javascript">
    <!--
    function a(){
        document.formname.cost_hidden.value = document.formname.cost_total.value;
    }
    // -->
    </script>
    "I have no special talent. I am only passionately curious." Albert Einstein

  3. #3
    Join Date
    Aug 2005
    Location
    USA
    Posts
    116
    Ok, I got that part, but let me ask this.

    How would you go about converting that into a float? I need to pass this as a float, not a string.

  4. #4
    Join Date
    Jun 2005
    Posts
    411
    actually, you could do it with php, on the page that proccesses the form information, just make a
    HTML Code:
    <input type="hidden" name="somename" value="<? echo $_POST['cost_total']; ?>">
    and that should work, but as im not sure how your script runs it might not be what your wanting.
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

  5. #5
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Quote Originally Posted by Heavy Metal
    actually, you could do it with php, on the page that proccesses the form information, just make a
    HTML Code:
    <input type="hidden" name="somename" value="<? echo $_POST['cost_total']; ?>">
    and that should work, but as im not sure how your script runs it might not be what your wanting.
    That's assuming that post-cost_total is set. It won't work on the client. b The source will look something like
    HTML Code:
    <input type="hidden" name="somename" value="the_data_in_the_post">

    However, that method will work if the page is refreshed or it's on a second page.
    "I have no special talent. I am only passionately curious." Albert Einstein

  6. #6
    Join Date
    Jun 2005
    Posts
    411
    it would be set obviously if it is submited, which should happen, otherwise, why would you be using a form if not to submit???
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

  7. #7
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    That's true, but I think that he wants it to be client-side.
    "I have no special talent. I am only passionately curious." Albert Einstein

  8. #8
    Join Date
    Jun 2005
    Posts
    411
    well, install php then, then it will still work on client side.
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

  9. #9
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Quote Originally Posted by Heavy Metal
    well, install php then, then it will still work on client side.
    PHP is server-side. I've never heard of PHP on client-side.
    "I have no special talent. I am only passionately curious." Albert Einstein

  10. #10
    Join Date
    Jun 2005
    Posts
    411
    yes, but you can install a localhost server on your machine, i used to use it often for developement. Anyways, if you have like Xp, you can put it on there without much problem. I forget exactly how, but its not all that hard.
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

  11. #11
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Okay, but what about the general public?
    "I have no special talent. I am only passionately curious." Albert Einstein

  12. #12
    Join Date
    Jun 2005
    Posts
    411
    well, the general public uses microsoft(sadly as they suck) which means that alot of people use windows which means that alot of people can install it, and they prob have something out for linux. ect... Like I said, its been a while, in fact, I have like php 3 on my local server, thats how long its been. Talk to nogdog or one of the smart ppls about it, they would know more than I would prob.
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

  13. #13
    Join Date
    Oct 2005
    Location
    Erie, PA
    Posts
    401
    I think he wants a script to handle the posted value. Or post it to the form from a previous page, so when they pressed the button then it can query PayPal or something like that.

    Don't know if we can help you accurately without a full explanation.

  14. #14
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Quote Originally Posted by Heavy Metal
    ... alot of people can install it ...
    But who actually does (besides programers)? It just doesn't seem like PHP can be run client-side; even if you do install it, your computer is like the server, and it is therefore server-side. Oh yeah, macintoshes come built in with disabled PHP4. You just have to enable it using UNIX commands. I did it, but I never use it.
    "I have no special talent. I am only passionately curious." Albert Einstein

  15. #15
    Join Date
    Jun 2005
    Posts
    411
    It is client side, because the server is a client sort of like a browser when your using it directly like that.
    HTML skill level: Good
    Javascript skill level: somewhere between poor and good
    php: good but still getting better
    sql: good but still getting better

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles