?
Solved

how to fill a div text from text on a form both on load and change of text in form

Posted on 2007-07-26
6
Medium Priority
?
1,462 Views
Last Modified: 2012-06-21
i came across this code
<div id=a>Filled with text</div>

<div id=b onclick="document.getElementById('a').innerHTML='Some Text'">Click Me</div>
how do i get it to change from my form text (upon load and upon change)

          <input   size="36" maxlength="35" value="<?php echo $Manufacturer;?>" name="Manufacturer" onChange="updatePicLink('')">

how do i put all this together

thank you in advance for any code and help you may provide.
0
Comment
Question by:Johnny
6 Comments
 
LVL 18

Expert Comment

by:bruno
ID: 19579998
i'm not sure i understand exactly what you want to happen, can you elaborate?
0
 
LVL 14

Accepted Solution

by:
steveberzins earned 2000 total points
ID: 19580001
ok, so, you have a div, that you want to change to what is in the Manufacturer textbox, when the page loads, and anytime the Manufacturer textbox value changes? why change it, if you can just set it the same on the server...?

something like:

<div id="a"><?php echo $Manufacturer;?></div>
<input value="<?php echo $Manufacturer;?>" name="Manufacturer" onChange="document.getElementById('a').innerHTML=this.value;" size="36" maxlength="35">
0
 
LVL 17

Expert Comment

by:gops1
ID: 19580014
Probably this is what you are looking for:

<html>
      <head>
            <head>
                  <title>Script Demo Gops</title>
                  <script language="javascript">
                        window.onload=function(){
                              updatePicLink(document.forms['test'].elements['Manufacturer'].value)
                        }

                        function updatePicLink(v){
                              var o=document.getElementById('a');
                              o.innerHTML=v;
                        }
                  </script>
            </head>
<body>
      <div id="a"></div>
      <br>
      <form name="test">
            <input name="Manufacturer" type="text" value="Manufacturer" onChange="updatePicLink(this.value)">
      </form>
</body>
</html>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Johnny
ID: 19580143
steveberzins is what im looking for kinda



im trying to show the value of the manufacturer value to the div as it loads and changes..so we have the onload part with the php statement(duh shoulda thought of that myself)

now the string we have is printing out
document.demoform.Manufacturer.value
as the text and not the value.. if we get this part fixed where all set. by the way the line has to have the updatepic too
so it read right now as
          <input   size="36" maxlength="35" value="<?php echo $Manufacturer;?>" name="Manufacturer" onChange="document.getElementById('a').innerHTML=this.value; updatePicLink('')">

thanks so far for the help and suggestions
0
 

Author Comment

by:Johnny
ID: 19580158
duh it does work i had the statement in the updatepic i was trying to get to work...forgot that one

so it does work thanks again
accepting steveberzins as answer as his was not only the one i used but the first working answer
0
 

Author Comment

by:Johnny
ID: 19580232
heres my final code snips so others can see how it works

<script language="JavaScript" type="text/javascript">
function updateDiv() {
document.getElementById('a').innerHTML = "Current Product - <?php echo $ID;?>: " + document.demoform.Manufacturer.value + ", " + document.demoform.Type.value;
}
</script>


          <input size="36" maxlength="35" value="<?php echo $Manufacturer;?>" name="Manufacturer" onChange="updateDiv(''); updatePicLink('')">



 <div align="left" id=a>Current Product - <?php echo$ID;?>: <?php echo $Manufacturer;?>, <?php echo$Type;?></div>
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question