SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast tosta's Avatar
    Join Date
    Sep 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need javascript function help inside js file

    Need javascript function help inside .js file

    I need to modify or fix the output of a function.

    so here it is: -----------

    this is where it outputs my variable:
    Code:
    <p class="pp_description"></p>
    (displays a variable)

    this is the one part of the large code(modifies or creates the variable ):
    Code:
    if(pp_descriptions[set_position]!=""){$pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position]));}else{$pp_pic_holder.find('.pp_description').hide();}
    The output that i need to change(or just add something to it): html(unescape(pp_descriptions[set_position])); (how do i modify it to get the output like I need.)

    I need to get the output to be like
    Code:
    <input value="$the_output" type="text">
    instead of
    Code:
    <p class="pp_description">$the_output</p>
    How can I get what I want?

    ----my knowledge about js---
    Tried like adding "things" to it but the html() function outputs the first value, so I need a solution, add something to the function, I never have written javascript myself, so I guess it's easy to people who know javascript more.
    -----

    Thank you!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by tosta View Post
    I need to modify or fix the output of a function.
    What you currently have is:

    Code javascript:
    if (pp_descriptions[set_position]!="") {
        $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position]));
    } else {
        $pp_pic_holder.find('.pp_description').hide();
    }

    The part that we're interested in is:

    Code:
    $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position]));
    So instead of setting the HTML content, you want to set an attribute called value instead:


    Code javascript:
    $pp_pic_holder.find('.pp_description').show().attr('value', unescape(pp_descriptions[set_position]));
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast tosta's Avatar
    Join Date
    Sep 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the answer! issue solved.


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
  •