i am not able to assign values ,can any one tell me whats wrong .... - <script>
-
function changeMySrc(nm,act)
-
{
-
alert("hi"+ nm );
-
if(act == 1)
-
{
-
-
dc = "document.getElementById('"+ nm +"')";
-
dc.src="http://bytes.com/images/delete.gif";
-
alert(dc.src);
-
hd_val = "documnet.getElementById('chk[" + nm + "]')";
-
hd_val.value = "0" ;
-
alert(hd_val.value);
-
-
-
-
}
-
else if (act == 0)
-
{
-
-
dc="document.getElementById('"+nm+"')";
-
dc.src="http://bytes.com/images/addbutton.gif";
-
alert(dc.scr);
-
hd_val = "document.getElementbyId('chk["+ nm+"]')";
-
hd_val.value = "1";
-
alert(hd_val.vlaue);
-
-
}
-
}
-
-
</script>
when i want to print values is gives me "undefined"
20 2117
Are u getting the alert at the line no: 4
and in the line alert(dc.scr); it must be src not scr.
Can u please post the whole code.
Regards
Ramanan Kalirajan
actually my code is too big . what i want to do is that i have a folder name , image showing folder is selected or not and a hidden box .
now if folder is selected , its showing "-" hidden box value is 1 image and now i want to deselect it . when i deselect it , image should chamge to "+" and hidden box value should become "0";
this is what i am trying to do but not getting sucess ....
Your code has quite a number of errors. For example, this line - dc = "document.getElementById('"+ nm +"')";
should be simply - dc = document.getElementById(nm);
No quotes needed. Also check for spelling mistakes.
thanks its working
but now the problem is that its only changing image once.
Have you made changes to the rest of your code? Post your updated code.
Thanks alot , its working perfactly
Excellent. Glad you managed to get it working.
Actually now further ....
i am displaying a hidden text box also with image , now i want that my value of hidden box also should reflected with the change of image ....
this is how my hidden box is coming from a database , i am making it an array because i want to apply batch updation for that further , but fisrt i want to manage value :
this is how hidden box is coming : - <?
-
include("conn.php");
-
$userID = $_GET["q"];
-
$qry = "select * from folder";
-
$result=mysql_query($qry);
-
echo "<table>";
-
$i=0;
-
while($row=mysql_fetch_array($result))
-
{
-
echo "<tr><td>".$row['folder_name']."</td>";
-
$qry1 = "select * from user_content_assign where folder_id = '".$row['folder_id']."' and user_id = '".$userID."'";
-
$result1=mysql_query($qry1);
-
$r = mysql_numrows($result1);
-
if($r <= 0)
-
{
-
echo "<td><img alt='not_selected' src='images/addbutton.gif' border='0' id = '".$row['folder_id']."' onclick='changeMySrc(this.alt,this.id);' ><input type='hidden'
-
-
name='userid' value='".$row['userID']."'><input type='hidden' id='act[i]' name='act[i]' value='".$row['active']."'><input type='hidden' name='fid[i]'
-
-
value='".$row['folder_id']."'></td>";
-
}
-
else
-
{
-
while($row1=mysql_fetch_array($result1))
-
{
-
if($row1['active'] == 1)
-
{
-
echo "<td><img alt='selected' src='images/delete.gif' border='0' id = '".$row['folder_id']."' onclick='changeMySrc(this.alt,this.id);' ><input type='hidden'
-
-
name='userid' value='".$row['userID']."'><input type='hidden' id= 'act[i]' name='act[i]' value='".$row1['active']."'><input type='hidden' name='fid[i]'
-
-
value='".$row1['folder_id']."'></td>";
-
}
-
else
-
{
-
echo "<td><img alt='not_selected' src='images/addbutton.gif' border='0' id = '".$row['folder_id']." onclick='changeMySrc(this.alt,this.id);'> <input type='hidden'
-
-
name='userid' value='".$row['userID']."'><input type='hidden' id='act[i]' name='act[i]' value='".$row1['active']."'><input type='hidden' name='fid[i]'
-
-
value='".$row1['folder_id']."'></td>";
-
}
-
}
-
}
-
echo "</tr>";
-
}
-
echo "</table>";
-
?>
And this is the java script i am using : - <script>
-
function changeMySrc(alt,id)
-
{
-
alert("hi"+ alt );
-
if(alt == "not_selected")
-
{
-
-
dc = document.getElementById(id);
-
dc.src="http://bytes.com/images/delete.gif";
-
dc.alt="selected";
-
alert(dc.src);
-
-
document.getElementById("act[id]").value="0";
-
-
-
-
-
}
-
else if(alt == "selected")
-
{
-
-
dc=document.getElementById(id);
-
dc.src="http://bytes.com/images/addbutton.gif";
-
dc.alt="not_selected";
-
alert(dc.src);
-
-
document.getElementById("act[id]").value="0";
-
-
-
-
-
-
}
-
}
-
-
</script>
i am trying to vhange value of hidden box , its showing me
act is not defined
any suggestions ?
Avoid [] in IDs. Make sure the ID is unique too. You can set the ID to "act".$id where $id is a number to make it unique.
i am still not getting how to change the value of hidden field "act" with respect of change in image .........
You have this line: - document.getElementById("act[id]").value="0";
In your PHP code, change the IDs of the hidden fields to make them unique, so that you can access them in the JavaScript code with something like: - document.getElementById("actid1").value="0";
i took array as i want to update multiple rows , if i change them to static values , i wont be able to update them in database
That's for the name, not the ID.
<input type='hidden' id='act".$i."' name='act[$i]' value='".$row['active']."'>
now i have done this but now what ? how to send value to call that value in javascript function ? So, that value can be changed......
$i was only an example. You can use the img ID as part of the ID, e.g. - <input type='hidden' id='act".$row['folder_id']."' name='act[]' value='".$row['active']."'>
then to refer to the hidden field you can use "act"+id
i am trying to ge value in javascript : - <script>
-
function changeMySrc(alt,id)
-
{
-
alert("hi"+ alt );
-
if(alt == "not_selected")
-
{
-
-
dc = document.getElementById(id);
-
dc.src="http://bytes.com/images/delete.gif";
-
dc.alt="selected";
-
alert(dc.src);
-
-
hd_val= document.getElementById("act"+id);
-
hd_val.value = "0" ;
-
alert(hd_val.value);
its giving me error , pls try to understand what i want ?
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use the tags in future.
Moderator.
@Shalini Bhalla
Check the source as generated in the browser and post that here, i.e. the HTML code, not PHP.
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title><MMString:LoadString id="insertbar/linebreak" /></title>
-
<link href="css/admin.css" rel="stylesheet" type="text/css" />
-
<script src="selectuser.js"></script>
-
<script src="call_insert.js"></script>
-
<style type="text/css">
-
<!--
-
a:link {
-
text-decoration: none;
-
}
-
a:visited {
-
text-decoration: none;
-
}
-
a:hover {
-
text-decoration: underline;
-
}
-
a:active {
-
text-decoration: none;
-
}
-
-->
-
</style>
-
<!-- Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved. -->
-
<!-- Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved. -->
-
<!-- Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved. -->
-
-
<script>
-
function changeMySrc(alt,id)
-
{
-
alert("hi"+ alt );
-
if(alt == "not_selected")
-
{
-
-
dc = document.getElementById(id);
-
dc.src="images/delete.gif";
-
dc.alt="selected";
-
alert(dc.src);
-
-
hd_val= document.getElementById("act"+id);
-
hd_val.value = "0" ;
-
alert(hd_val.value);
-
-
-
-
-
-
-
-
}
-
else if(alt == "selected")
-
{
-
-
dc=document.getElementById(id);
-
dc.src="images/addbutton.gif";
-
dc.alt="not_selected";
-
alert(dc.src);
-
-
}
-
}
-
-
-
-
</script>
-
-
-
</head>
-
-
<body class="oneColElsCtr" >
-
-
<div id="container">
-
<div id="mainContent"><br />
-
<br />
-
<br />
-
<br />
-
-
<span class="mainheading">Administration Module</span><br />
-
<span class="topnav"><br />
-
</span><a href="#" class="topnav">Create Folder</a><span class="topnav"> | </span><a href="#" class="topnav">Add Content</a><span class="topnav"> | </span><a href="#" class="topnav">Video Archive</a><span class="topnav"> | </span><a href="#" class="topnav">Create User</a><span class="topnav"> | </span><a href="#" class="topnav">Assign User</a><span class="topnav"> | <a href="#"> </a></span><a href="#" class="topnav">Account Archive</a><span class="topnav"> | </span><a href="#" class="topnav">Account Overview</a><br />
-
-
<br />
-
<br />
-
<br />
-
<br />
-
<br />
-
<br />
-
<br />
-
<div class="formContainer">
-
<form id="form1" name="form1" method="POST" action="video_archive.php" >
-
-
<table width="100%" border="0">
-
<tr>
-
<td width="45%" valign="top"><span class="mainheading2">Video Archive </span></td>
-
<td valign="top"> </td>
-
<td width="45%" valign="top"><span class="mainheading2">Create User</span></td>
-
</tr>
-
<tr>
-
<td valign="top"><table width="100%" border="0">
-
-
<tr >
-
<td width="47%" class="foldername1" ><b>Html</b></td>
-
<td width="53%"></td>
-
</tr>
-
-
<tr>
-
<td colspan="2">test.html</td>
-
</tr>
-
<tr >
-
-
<td width="47%" class="foldername1" ><b>Php</b></td>
-
<td width="53%"></td>
-
</tr>
-
-
<tr>
-
<td colspan="2">test1.php</td>
-
</tr>
-
</table>
-
</td>
-
-
<td valign="top"> </td>
-
<td valign="top"><table width="100%" border="0">
-
<tr>
-
<td width="47%"><label>User Name</label></td>
-
<td width="53%"><input type="text" name="username" /></td>
-
</tr>
-
<tr>
-
<td><label>
-
-
Password </label>
-
<label> </label></td>
-
<td><input type="password" name="pass" /></td>
-
</tr>
-
<tr>
-
<td><label>
-
</label>
-
<label>Email ID </label></td>
-
-
<td><input type="text" name="email" /></td>
-
</tr>
-
-
<tr>
-
<td><label>
-
Company Name </label></td>
-
<td><input type="text" name="company" /></td>
-
</tr>
-
<tr>
-
<td><div align="right">
-
-
</div></td>
-
<td>
-
<div align="right">
-
<label>
-
<input type="submit" name="Submit" value="Submit" />
-
</label>
-
</div></td>
-
</tr>
-
</table></td>
-
-
</tr>
-
<tr>
-
<td valign="top" class="mainheading2"> </td>
-
<td valign="top"> </td>
-
<td valign="top" class="mainheading2"> </td>
-
</tr>
-
<tr>
-
<td valign="top" class="mainheading2"> </td>
-
<td valign="top"> </td>
-
-
<td valign="top" class="mainheading2">Assign User </td>
-
</tr>
-
-
-
-
<tr>
-
<td valign="top" class="mainheading2"> </td>
-
<td valign="top"> </td>
-
<td valign="top" class="mainheading2">
-
<select name="select" onchange="showUser(this.value)">
-
<option value="Select" selected >Select User</option>
-
-
<option value = 1 >abc</option>
-
<option value = 2 >hij</option>
-
<option value = 3 >shalini</option>
-
<option value = 4 >fdgvfd</option>
-
<option value = 6 >neeta</option>
-
</select></td>
-
-
</tr>
-
<tr>
-
<td valign="top" class="mainheading2"> </td>
-
<td valign="top"></td>
-
<td valign="top" class="mainheading2"><table width="323">
-
<tr><td width="241">
-
<div id="txtHint"></div>
-
</td></tr></table></td>
-
</tr>
-
<tr><td><input type='submit' value='Assign' name='assign'>
-
-
</table>
-
-
</form>
-
<br />
-
</div>
-
<br />
-
-
<!-- end #mainContent -->
-
</div>
-
<!-- end #container --></div>
-
</body>
-
</html>
-
Are you sure you've got the right page? Where's the image and hidden fields?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jenny |
last post by:
Hi,
Can I create an array of tags by assigning same name to these tags?
For example, I have two <p> tags with the same name t1. But
document.all.b.value=document.all.t.length
does not...
|
by: adamrfrench |
last post by:
Let it be mentioned that Javascript is not my forte, so the solution to
this could very well be a simple one.
I am working on an AJAX function where I can pass a URL and the target
ID in, and...
|
by: Ricky W. Hunt |
last post by:
How does VB.NET determine comparing vs. assigning?
For instance, if "checkbox1.checked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.checked = True" by...
|
by: weston |
last post by:
I've got a piece of code where, for all the world, it looks like this
fails in IE 6:
hometab = document.getElementById('hometab');
but this succeeds:
hometabemt =...
|
by: Phil Latio |
last post by:
I have 2 virtually identical tables and wish to move data between them.
Basically one table is called "live_table" and the other is named
"suspended_table" and the only difference is that the...
|
by: BobRoyAce |
last post by:
In my property declaration, shown below, is it
correct to assign _DeptID = Value like I would have if it was just a
plain ole Integer, or is this like setting two objects equal to each
other where...
|
by: Sourav |
last post by:
Suppose I have a code like this,
#include <stdio.h>
int *p;
void foo(int);
int main(void){
foo(3);
printf("%p %d\n",p,*p);
|
by: getmeidea |
last post by:
Hi,
I am using JDK 1.5.
I have a program like this. Here i am directly assigning value to one object.
It does'nt give me any compile time or run time error. In java we dont have access to any...
|
by: miken32 |
last post by:
In PHP, if a function returns an array it's fairly common to capture
its return values like this:
<?php
list($foo, $bar, $baz) = some_function_that_return_an_array();
?>
In Javascript, would...
|
by: The Pythonista |
last post by:
I've been wondering for a while about whether assigning to __class__ is
bad form or not. Specifically, I mean doing so when some other method of
implementing the functionality you're after is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |