473,545 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php generated html needs simple javascript function, yet my javascriptsux

mk
Greetings all - im new to this newsgroup so pls dont flame me :p
I need some help! Please view the html below in a browser. Or goto this
url -http://firebrain.co.uk/java-problem.htm

(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each textbox
to zero either in the col or row depending on which button is clicked.

Function summery:
If you click on a X button on the right hand side of the table it resets
all the textboxes in that row. And if you click one of the X buttons
along the base of the table it will reset all the textfields in the column.

I hope the way I named my fields can be for>looped in javascript :)

If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.

Please please please - this is for a client and im running low on time
Any help would be much appreciated! Any questions just ask

Please reply to this message or (preferably) send me an email to
ja********@fire brain.co.uk

Thank you

--------------------------------------

<form name='availabil ity'>
<p><table cellpadding=3>
<tr>
<td rowspan=2 valign=bottom id='greybg'><b> Dates</b></td>
<td colspan=5 id='purpbg'><b> Building One</b></td>
<td colspan=3 id='purp2bg'><b >Building Two</b></td>
</tr>

<tr>
<td id='purpbg' valign=top style='font-size:7pt;'>Stud io Apartment</td>
<td id='purpbg' valign=top style='font-size:7pt;'>Exec utive Studio
Apartment</td>
<td id='purpbg' valign=top style='font-size:7pt;'>One Bedroom Apartment</td>
<td id='purpbg' valign=top style='font-size:7pt;'>Exec utive One Bedroom
Apartment</td>
<td id='purpbg' valign=top style='font-size:7pt;'>Two Bedroom Apartment</td>
<td id='purp2bg' valign=top style='font-size:7pt;'>One Bedroom
Apartment</td>
<td id='purp2bg' valign=top style='font-size:7pt;'>Two Bedroom
Apartment</td>
<td id='purp2bg' valign=top style='font-size:7pt;'>Exec utive Two Bedroom
Apartment</td>

<td id='greybg'><b> Close Out</b></td>
</tr>
<tr>
<td id='r2'><small> <b>2006-07-27</b><br>Thursday 27th, July
2006</small></td>
<td id='r2' align=center>
<input name='slots[2006-07-27][1]' type='text' value='1' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][2]' type='text' value='1' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][3]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>

<input name='slots[2006-07-27][4]' type='text' value='1' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][5]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][6]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][7]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-27][8]' type='text' value='0' size=2>
</td>
<td id='r3' align=center>
<input name='close[2006-07-27]' type='button' value='X' size=2>
</td>

</tr>
<tr>
<td id='r1'><small> <b>2006-07-28</b><br>Friday 28th, July 2006</small></td>
<td id='r1' align=center>
<input name='slots[2006-07-28][1]' type='text' value='1' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][2]' type='text' value='1' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][3]' type='text' value='1' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][4]' type='text' value='0' size=2>
</td>

<td id='r1' align=center>
<input name='slots[2006-07-28][5]' type='text' value='1' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][6]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][7]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-28][8]' type='text' value='0' size=2>
</td>
<td id='r3' align=center>
<input name='close[2006-07-28]' type='button' value='X' size=2>
</td>
</tr>
<tr>

<td id='r2'><small> <b>2006-07-29</b><br>Saturday 29th, July
2006</small></td>
<td id='r2' align=center>
<input name='slots[2006-07-29][1]' type='text' value='1' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][2]' type='text' value='1' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][3]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][4]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][5]' type='text' value='0' size=2>

</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][6]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][7]' type='text' value='0' size=2>
</td>
<td id='r2' align=center>
<input name='slots[2006-07-29][8]' type='text' value='0' size=2>
</td>
<td id='r3' align=center>
<input name='close[2006-07-29]' type='button' value='X' size=2>
</td>
</tr>
<tr>
<td id='r1'><small> <b>2006-07-30</b><br>Sunday 30th, July 2006</small></td>

<td id='r1' align=center>
<input name='slots[2006-07-30][1]' type='text' value='1' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][2]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][3]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][4]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][5]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][6]' type='text' value='0' size=2>

</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][7]' type='text' value='0' size=2>
</td>
<td id='r1' align=center>
<input name='slots[2006-07-30][8]' type='text' value='0' size=2>
</td>
<td id='r3' align=center>
<input name='close[2006-07-30]' type='button' value='X' size=2>
</td>
</tr>
<tr>
<td id='greybg'><b> Close Out</b></td>
<td id='r3' align=center>
<input type='button' name='closeRang e[0]' value='X'>
</td>

<td id='r3' align=center>
<input type='button' name='closeRang e[1]' value='X'>
</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[2]' value='X'>
</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[3]' value='X'>
</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[4]' value='X'>
</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[5]' value='X'>
</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[6]' value='X'>

</td>
<td id='r3' align=center>
<input type='button' name='closeRang e[7]' value='X'>
</td>
<td id='r3'>&nbsp;</td>
</tr>
<tr><td height=100 id='r1' valign=middle align=center colspan=10><inp ut
type='submit' accesskey='s' name='apply_cha nges' value='Apply
Changes'></td></tr>
</table>
</form>

Jul 27 '06 #1
5 1702
mk said the following on 7/27/2006 4:46 PM:
Greetings all - im new to this newsgroup so pls dont flame me :p
It is not a person's newness to this group that gets them flamed, it is
the behavior and/or expectations of people that get them flamed.
I need some help! Please view the html below in a browser. Or goto this
url -http://firebrain.co.uk/java-problem.htm
It's not a Java-problem but ok.
(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each textbox
to zero either in the col or row depending on which button is clicked.
Ok, loop through the form, check for the indexOf your identifying string.
Function summery:
If you click on a X button on the right hand side of the table it resets
all the textboxes in that row. And if you click one of the X buttons
along the base of the table it will reset all the textfields in the column.

I hope the way I named my fields can be for>looped in javascript :)
All form elements can be for>looped, irrelevant of the names. Your
naming convention make it simpler, somewhat, but the naming convention
could be better. column1row1 and so on, so that the name tells you the
column and the row it is in.
If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.
There is, I gave it above. Search the archives on how to do it.
Please please please - this is for a client and im running low on time
Is your client going to pay me for writing the code for the project?
Any help would be much appreciated! Any questions just ask
Please reply to this message or (preferably) send me an email to
ja********@fire brain.co.uk
Don't ask, and definitely don't expect, an email reply. You ask in
Usenet, you get answered in Usenet.

P.S. You only need one function, not two, to do what you want to do.

Here is you a start:

function resetColOrRow(i dentifier,formR ef){
totalElements = formRef.length;
for (i=0;i<totalEle ments;i++){
if (formRef.elemen ts[i].name.indexOf(i dentifier) != -1)
formRef.element s[i].value = 0;
}
}

And call it as such:
resetColOrRow('[1]',this.form)
resetColOrRow('[2006-07-29]',this.form)

Where the first parameter to the function call is the unique part of the
element name you want to match.

It can be made more efficient, I just don't feel like it right now. It
should be tested as well.

There is a bug in that code, related to your HTML as much as to my code,
I will leave that as an exercise for you to discover.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 27 '06 #2
mk wrote:
Greetings all - im new to this newsgroup so pls dont flame me :p
I need some help! Please view the html below in a browser. Or goto this
url -http://firebrain.co.uk/java-problem.htm

(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each textbox
to zero either in the col or row depending on which button is clicked.

Function summery:
If you click on a X button on the right hand side of the table it resets
all the textboxes in that row. And if you click one of the X buttons
along the base of the table it will reset all the textfields in the column.

I hope the way I named my fields can be for>looped in javascript :)

If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.
Randy gave you one algorithm, another is if the button is in the last
cell of a row, clear the row - otherwise clear the column. Very simple
logic that is dependent on your table structure rather than names/ids.

The implementation would be marginally easier if colgroup or col
elements had a nodeList of the TD elements that belonged to them ...
but no such luck.

--
Rob

Jul 28 '06 #3
mk
RobG wrote:
mk wrote:
>>Greetings all - im new to this newsgroup so pls dont flame me :p
I need some help! Please view the html below in a browser. Or goto this
url -http://firebrain.co.uk/java-problem.htm

(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each textbox
to zero either in the col or row depending on which button is clicked.

Function summery:
If you click on a X button on the right hand side of the table it resets
all the textboxes in that row. And if you click one of the X buttons
along the base of the table it will reset all the textfields in the column.

I hope the way I named my fields can be for>looped in javascript :)

If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.


Randy gave you one algorithm, another is if the button is in the last
cell of a row, clear the row - otherwise clear the column. Very simple
logic that is dependent on your table structure rather than names/ids.

The implementation would be marginally easier if colgroup or col
elements had a nodeList of the TD elements that belonged to them ...
but no such luck.
thanks :)

Jul 28 '06 #4
mk
Randy Webb wrote:
mk said the following on 7/27/2006 4:46 PM:
>Greetings all - im new to this newsgroup so pls dont flame me :p


It is not a person's newness to this group that gets them flamed, it is
the behavior and/or expectations of people that get them flamed.
>I need some help! Please view the html below in a browser. Or goto
this url -http://firebrain.co.uk/java-problem.htm


It's not a Java-problem but ok.
>(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each
textbox to zero either in the col or row depending on which button is
clicked.


Ok, loop through the form, check for the indexOf your identifying string.
>Function summery:
If you click on a X button on the right hand side of the table it
resets all the textboxes in that row. And if you click one of the X
buttons along the base of the table it will reset all the textfields
in the column.

I hope the way I named my fields can be for>looped in javascript :)


All form elements can be for>looped, irrelevant of the names. Your
naming convention make it simpler, somewhat, but the naming convention
could be better. column1row1 and so on, so that the name tells you the
column and the row it is in.
>If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.


There is, I gave it above. Search the archives on how to do it.
>Please please please - this is for a client and im running low on time


Is your client going to pay me for writing the code for the project?
>Any help would be much appreciated! Any questions just ask
Please reply to this message or (preferably) send me an email to
ja********@fire brain.co.uk


Don't ask, and definitely don't expect, an email reply. You ask in
Usenet, you get answered in Usenet.

P.S. You only need one function, not two, to do what you want to do.

Here is you a start:

function resetColOrRow(i dentifier,formR ef){
totalElements = formRef.length;
for (i=0;i<totalEle ments;i++){
if (formRef.elemen ts[i].name.indexOf(i dentifier) != -1)
formRef.element s[i].value = 0;
}
}

And call it as such:
resetColOrRow('[1]',this.form)
resetColOrRow('[2006-07-29]',this.form)

Where the first parameter to the function call is the unique part of the
element name you want to match.

It can be made more efficient, I just don't feel like it right now. It
should be tested as well.

There is a bug in that code, related to your HTML as much as to my code,
I will leave that as an exercise for you to discover.
Thank you

Jul 28 '06 #5
mk
Randy Webb wrote:
mk said the following on 7/27/2006 4:46 PM:
>Greetings all - im new to this newsgroup so pls dont flame me :p


It is not a person's newness to this group that gets them flamed, it is
the behavior and/or expectations of people that get them flamed.
>I need some help! Please view the html below in a browser. Or goto
this url -http://firebrain.co.uk/java-problem.htm


It's not a Java-problem but ok.
>(Assuming you have seen the rendered code)
Basically I need the X buttons to change all the values of each
textbox to zero either in the col or row depending on which button is
clicked.


Ok, loop through the form, check for the indexOf your identifying string.
>Function summery:
If you click on a X button on the right hand side of the table it
resets all the textboxes in that row. And if you click one of the X
buttons along the base of the table it will reset all the textfields
in the column.

I hope the way I named my fields can be for>looped in javascript :)


All form elements can be for>looped, irrelevant of the names. Your
naming convention make it simpler, somewhat, but the naming convention
could be better. column1row1 and so on, so that the name tells you the
column and the row it is in.
>If you have not seen the HTML in a browser yet please do so because im
sure there is a very easy solution to my problem.


There is, I gave it above. Search the archives on how to do it.
>Please please please - this is for a client and im running low on time


Is your client going to pay me for writing the code for the project?
>Any help would be much appreciated! Any questions just ask
Please reply to this message or (preferably) send me an email to
ja********@fire brain.co.uk


Don't ask, and definitely don't expect, an email reply. You ask in
Usenet, you get answered in Usenet.

P.S. You only need one function, not two, to do what you want to do.

Here is you a start:

function resetColOrRow(i dentifier,formR ef){
totalElements = formRef.length;
for (i=0;i<totalEle ments;i++){
if (formRef.elemen ts[i].name.indexOf(i dentifier) != -1)
formRef.element s[i].value = 0;
}
}

And call it as such:
resetColOrRow('[1]',this.form)
resetColOrRow('[2006-07-29]',this.form)

Where the first parameter to the function call is the unique part of the
element name you want to match.

It can be made more efficient, I just don't feel like it right now. It
should be tested as well.

There is a bug in that code, related to your HTML as much as to my code,
I will leave that as an exercise for you to discover.
excellent "starter" function - it turned out to do the entire job very
nicely indeed :) you were correct about the html bug(s) - i found there
were 2 - first was the fact i gave the buttons a name in the same format
as the textboxes (therefore the button would change to 0 also lol) and
secondly my naming convention for the bottom row of buttons changed the
col values to the left (i.e. -1) of the reference

everything fixed now and working perfectly here is the final code if
anyone is interested:

<script language="JavaS cript">
function resetColOrRow(i dentifier,formR ef){
totalElements = formRef.length;
newVal=prompt(" Please enter new value for entire row/col","0");
if(!newVal.matc h(/^\d+$/)){
alert("Was not a number");
}else if(newVal.lengt h>2){
alert("Number was too long");
}else{
for (i=0;i<totalEle ments;i++){
if (formRef.elemen ts[i].name.indexOf(i dentifier) != -1)
formRef.element s[i].value = newVal;
}
}
}
</script>

Thanks again :)

Jul 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2583
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file (that part's not here -- spotlighting the problem code): --------BEGIN CODE PAGE------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
9
2707
by: quikquic | last post by:
Suppose I download a html file with javascript in it, for example, <html> <body> <script language="JavaScript"> document.write("Hello"); </script> </body> </html>
0
3535
by: Jimmy Cerra | last post by:
I recently came up with a cool little stylesheet for definition lists. There is a small demostration for the impatient . I hope this helps someone. Here's how I did it. Definition lists are usually styled something like: ] Term ] A tab of white space followed by the definition ] By
12
12401
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server...
1
2402
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML GENERATED BY FUNCTION. Here'e the point: I'm writing a simple website for showing my photographs. It has a central page with many links (as many as...
2
3455
by: christine.nguyen | last post by:
Hello all, I have a page called test.html. Within test.html I have an iframe whose source is mypage.html. When mypage.html loads, it dynamically creates a javascript element which contains a function called doIt() and attaches it to the parent page, which is test.html. I have a button on test.html that then needs to call the dynamically...
5
2206
by: dwmartin18 | last post by:
Hello everyone. I have quite the puzzling problem with a script I have been working on lately. I have created a function that can be called to create a new html element (e.g. input, select, div, etc.). It is used as follows: addElementToPage("writeroot", "input", "type:button, text:testText, value:testvalue, onclick:test1") The first...
18
2592
by: bning | last post by:
Hmm this forum really doesn't give you long enough to type in your question before logging you out.. well here goes my second attempt: I'm trying to teach myself javascript with dom scripting and am attempting to write an application as I learn. It's been going fine but I've ran into a problem which is driving me crazy. I'll start off by...
5
3829
by: NuberSteve | last post by:
I'm very new to using CSS and also the concept of slices for mouse-overs, and have made my first attempt at using ImageReady to generate slices of a world map. I basically wanted a map that would show various countries appearing to be depressed when "moused-over". To keep it simple at first, I just decided to try two countries. After copying...
0
7468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7423
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7757
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5329
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
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 we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.