Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-18-2006, 02:52 PM Adding info to a DIV
Registered User

Posts: 29
Trades: 0
I know I know how to do this but...

I have a form with two input boxes for two different values. I have three buttons labeled ONE, TWO and THREE. You type info into the fields and click whatever button. If you click TWO, then the information is associated with TWO.
Ok, now I got three DIVs to display what is in ONE, TWO and THREE respectively.
What I want is a function that reads in the input values, formats them and sends them to the appropriate DIV. I have all of it but the last part. Whats the DOM for doing this?

In case what I say is confusing...

Code:
<html>
<head>

    <title> xxx </title>
    
    <script type="text/javascript">
    <!--
        function playerCard(card) {
            var pName = document.getElementByName('player_name');
            var tName = document.getElementByName('team_name');
            var info = pName + " plays for the " + tName;
        }
    //-->
    </script>

</head>

<body>

    <form name="card_form">
        <p>Player Name: <input type="text" name="player_name" /></p>
        <p>Team Name: <input type="text" name="team_name" /></p>
        <p>
            <input type="button" value="Card 1" onClick="playerCard('1')" />
            <input type="button" value="Card 2" onClick="playerCard('2')" />
            <input type="button" value="Card 3" onClick="playerCard('3')" />
        </p>
    </form>
    
    <div id="card1"> &nbsp; </div>
    <div id="card2"> &nbsp; </div>
    <div id="card3"> &nbsp; </div>
    
</body>
</html>
Inside the script function, I want it to put the variables into the appropriate DIV, depending on the button clicked.
wkdown is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-18-2006, 03:33 PM Re: Adding info to a DIV
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Add this into your function...

document.getElementById("card" + card).innerHTML = info;
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 10-18-2006, 06:39 PM Re: Adding info to a DIV
Registered User

Posts: 29
Trades: 0
innerHTML ... I know I knew how to do it, just had a brain fart ... thanks alot
wkdown is offline
Reply With Quote
View Public Profile
 
Old 10-19-2006, 02:25 AM Re: Adding info to a DIV
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
All that you can do is to archive the acctualy id of that div by using InnerHTML
seomumbai is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding info to a DIV
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32302 seconds with 12 queries