Web Hosting Talk







View Full Version : JavaScript help needed! (Involves textfields and checkboxes)


sachit64
11-16-2003, 03:48 PM
Since I can't post URLs, I'll try to describe you the URL.

It's a geocities. My then it's my username. Then the page is called TEST... and it's an HTML document.

Alright, I got this assignement due for my employer next week (it's coop, so don't think I get paid to do this). Right now, I wanna get the JavaScript part of it done. You can ignore that crap on the top... I was just experimenting and forgot to take it out.

What I want to currently make it do, is so that you can check all rows you want to edit, and then click Edit Selected.

The contents of the rows will appear in text fields below it for editing. After you edit them, you can click an Update button to put the newly editted stuff back into the rows. (Kinda like refreshing them).

Also... if you're up to it, a button to add more rows if necessary.

After this is done, I'll ask someone who's good in PERL to help me save all the variables in a document.

THANK YOU SO MUCH IF YOU CAN HELP ME FIND A CODE TO DO THIS.

-s64

Burhan
11-16-2003, 04:08 PM
Some DOM and Javascript can help you out. First, lets set up a simple form :

<input type="checkbox" id="field1select" />Select Field One
<input type="text" id="field1" />

<a href="javascript:" onclick="edit()">edit fields</a>

<input type="text" id="editfield1" />

<a href="javacript:" onclick="save()">save</a>

Now for the script :

function edit()
{

if (document.getElementById('field1select').checked) {
// checkbox is checked; do something
document.getElementById('editfield1").value = document.getElementById('field1').value;
}
}

function save()
{

document.getElementById('field1').value = document.getElementById('editfield1').value;
}


Slice and dice as necessary. If you want more information, check devedge (http://devedge.netscape.com)

sachit64
11-16-2003, 04:44 PM
I REALLY appreciate your help, but I forgot to mention I know NOTHING about JavaScript.

I tried running your script and I'm totally lost.

Could you paste the script along with the HTML and how it's suppost to look like?

Also, when I was running your script, the buttons didn't work. They just went to a broken linked page.

-s64

Burhan
11-16-2003, 05:02 PM
I posted the code with the javascript and a link where you can learn more about it.

However, I didn't post any code for any buttons. You probably just copy pasted my code without reading it and are wondering why it doesn't work.

Am I getting close? :mad:

sachit64
11-16-2003, 05:06 PM
Yeah, you're right, I just copied and paste the code and stuff.

But that link didn't really help. As I said, I know NOTHING about JavaScript. So I wouldn't even know the first place to start.

-s64

Burhan
11-16-2003, 05:33 PM
I told you were to start -- devedge (http://devedge.netscape.com) which, if you would have bothered to search, you would have realized is a site that has tons of tutorials on javascript.

Since I feel sorry about my last post and I feel that I shouldn't have reacted that bad, I put up a sample page (http://www.meidomus.com/temp/rtfm.html) at my website.

I am not going to do your work for you, because you will then never learn.

sachit64
11-16-2003, 08:27 PM
I appreciate your help, but I got 2 days to give this in and I don't got time to do tutorials. Thats why I'm relying on kind people like you to help me out.

Now if you saw my site you saw in each row, there were 3 "variables". Is there any way to make 3 textfields appear when I want editting?

-s64

sachit64
11-17-2003, 02:55 PM
Let me rephrase my question again.

Can you help me make the textfields and checkboxxes and stuff come in arrays? I tried doing it, but I don't know how to label the textfields in HTML, since you can use Array[1] stuff.

-s64