Results 1 to 6 of 6

Thread: Text field assigned also to hidden fields

  1. #1
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Text field assigned also to hidden fields

    Good Morning,

    I want a text field's value to populate/copy on submission to 2 hidden fields value that resides within the same page. Example below

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

    <input type="text" name="county" size="5" maxlength="5" value="55555" />

    <input type="hidden" id="age" name="yourcounty" value"" />
    <input type="hidden" id="DOB" name="ourcounty" value"" />


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

    Could this be done with javascript or anyother way maybe

    For you information this will be sent to a php file

    Please could you advise how this could be possible

    Regards

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Can be done. Makes little sense. If it is being submitted via PHP anyway, PHP may just take the value from the first input and use it.

    Also, using javascript for something that can be done with no additional server or client side overhead not only compromises the utility of the page, but wastes time/client resources too.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Hello scheuer1,

    Thanks for the reply.

    This is a temporary fix to a problem i have as the software I'm using is encrypted in such a way that i have to do this until i find a better solution.

    Please give me a demonstration how this could be done?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <form action="#"
    onsubmit="var e = this.elements, v = 'value', n = 'county';
    e['your'+n][v] = e['our'+n][v] = e[n][v]; return true;">
    <input type="text" name="county" size="5" maxlength="5" value="55555">
    <input type="hidden" id="age" name="yourcounty" value"">
    <input type="hidden" id="DOB" name="ourcounty" value"">
    <input type="submit" value="Go!">
    </form>
    But, as I was hinting at, with javascript disabled, this will not work. Also, since the value of "county" is already known in the PHP submit environment, it would be easier and better to set whatever you are currently setting from "yourcounty" and "ourcounty" from "county". The result would be the same, no javascript required.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Jhon
    Thank you for your time and patience. I will get on the case with my project in the morning.

    regards

  6. #6
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Hay Jhon,

    Im trying to create some amendments within some form fields as the files that need to be adjusted in the php scipts are encrypted.

    So im forced to use a work around. I'll explane best what i want to do via the very simple php script below

    first the form fields (all field names are related to there php objects)


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

    <--! this is the "title" field -->

    <td><input type="text" name="title" style="width: 100%" value="we are her" /></td>

    <--! this is the "categories" field -->
    <td><select name="categories[]" id="categories" multiple="multiple" class="inputbox" size="7" ></td>

    <--! this is the "Number of Bedrooms" field -->
    <td ><select name="fields[39]" id="fields39" size="1" style="width:100%"><option value="" >- Number of Bedrooms -</option>

    <--! this is the "Property Type" field -->

    <td ><select name="fields[38]" id="fields38" size="1" style="width:100%"><option value="" >- Property Type -</option>

    <--! this is the "City" field -->
    <td><input type="text" size="20" name="fields[18][city]" value="london"/> </td>

    <--! this is the "state" field -->

    <td align="right"><input type="text" size="20" name="fields[18][state]" value=""/> </td>

    <--! this is the "country" field -->
    <td align="right"><input type="text" size="20" name="fields[18][country]" value=""/> </td>

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

    now the php amendment.


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

    $prefix = 'my house ';
    $noRooms = ' ' . $object->Number_of_Bedrooms;
    $proType = ' ' . $object->Property_Type;
    $city = ' ' . $object->City
    $county = ' ' . $object->state
    $country = ' ' . $object->Country

    $object->title = $prefix . $noRooms . $proType . $city . $state . $country;

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

    and for the second adjustment

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

    $object->title = $object->country;

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

    how could i have the same disired effect in Javascript or maybe theres another solution?

    Thanks in advanced

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
  •