473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to insert a value into value="" attribute fro a javascript?

1 New Member
Dear All,

I'm new to this!

I wanna insert selected values from form "SaveModel" to form "SaveMake" [HTML]<input name="makeID" value="<<<<need to insert here(x)>>>>">[/HTML]
&
[HTML]<input name="make" value="<<<<need to insert here(optvalue)>>>>">[/HTML]

when i try it works only for the selected value and in an instance it clears the <input...>.

Please help me on this.


This is my Java Script.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function alertMake(){
  3.     var x = document.getElementById("selectMake").selectedIndex;
  4.     var optvalue = document.getElementsByTagName("option")[x].text;
  5.     var ex = "This will update all the Models under Make " + optvalue;
  6.     var r=confirm(ex)
  7.   if (r==true)
  8.     {
  9.     document.getElementById('min').innerHTML= SaveMake.makeID.value = x;
  10.     document.getElementById('mine').innerHTML= SaveMake.make.value = optvalue;
  11.  
  12.     }
  13.   else
  14.     {
  15.     optvalue = "";
  16.     x = "";
  17.     document.getElementById('min').innerHTML= SaveMake.makeID.value = x;
  18.     document.getElementById('mine').innerHTML= SaveMake.make.value = optvalue;
  19.  
  20.     }
  21.  
  22. }
  23. </script>
  24.  
This is a part of my SaveMMY.php

[PHP]<form action="SaveMMY.php" name="SaveMake" method="post">
Make ID: <input id="min" name="makeID" type="text" value="" size="5" readonly="true">
Make:<input type="text" id="mine" name="make" value="<?php if(isset($EditMake)) echo ($make) ;?>">
<input type="submit" name="SaveMake" value="Save">
</form>

<form action="SaveMMY.php" name="SaveModel" method="post">
Make: <select name="selectMake">
<option value="0">Select Make</option>
<?php echo ($allMakesHtml); ?>
</select>
<input type="submit" name="EditMake" value="Edit Make" onClick="alertMake()" >
</form>[/PHP]
Oct 6 '07 #1
1 6042
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

Change line 9 in your JavaScript to:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('min').value = x;
and similarly for line 10, 17 and 18. You've accessed the element. It has a value attribute. Use it instead of innerHTML.

Please use code tags when posting code:

[CODE=javascript]
Your JavaScript code goes here...
[/code]
Oct 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Demoso | last post by:
Hi What's wrong with this line: document.write('<input style="width: 260px;" type="button" id="button2" onmouseover="mover(\'button2\',\'green\');" onmouseout="mover(\'button2\',color2);" ...
5
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
4
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
1
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I have a simple XML file which is loaded into a XmlDocument, xDom. What the number 1 after each element, for example <PA>, is called in XML concept? What kind of C# function can be used to get this...
3
by: Twanne | last post by:
Hi, I've got a table called Aerosol and a table called LinkTabel. Now I do an update to a table from an excell sheet, this table is called ExportAerosol. So far so good, the import works...
11
by: dhaval321 | last post by:
Hello Guys, I have very strange problem . the attribute of drop down box(value) is perfectly running in firefox but it gives no value in Internet explorer. So kindly suggest me wht to do?
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.