Jump to content

[SOLVED] i want everything in the div to be the input


gevo12321

Recommended Posts

ok so i have a webpage withe different div tags and i want the div tag to be the input button is ths possible?

 

i am asking this because i want to make dynamic tabs(the tabs r in a div) where if u click on a tab, it changes without reloading the page.

 

if u dont know what im talking about, its kind of like the yahoo home page where if u click on the images tab the page doesnt reload but just changes the way it looks and searches in a different database.

 

the webpage im trying to put this on is gevsta.com/test

Link to comment
Share on other sites

if they remove the div and replace it with a textfield, wouldnt it look different?

 

Yes. Otherwise how would you know that you could type in the textarea? It looks different when you click on that site you linked to right?

 

what would be a sample code of this?

 

Google 'ajax tutorials', or 'ajax scripts'. It's not a little piece of 5-line code, it's a combination of 2 or 3 scripts (javascript and a server-side language) combined with some (X)HTML and CSS.

Link to comment
Share on other sites

It doesn't even have to be an anchor - you can add an onclick handler to any tag.

 

Hehe, I completely forgot about that! ... But, if you were to add an onclick handler to any old tag, then the website wouldn't downgrade nicely to non-JS enabled users. yahoo is a good example of HOW YOU SHOULD do it.  ;)

Link to comment
Share on other sites

im not sure if this is what u mean but this is what i think u mean:

 

u put the div as a link, and when u click it, it changes the div to another?

 

is that what u mean?

 

and if so would u be able to just show me the code on the html side. because when i click on the div and it changes, i want something else to change too. something i didnt click. ie: if ur in one tab and u click the other, the tab u r in changes the way it looks, and the one u clicked changes the way it looks.

 

im sorry if i sound like a noob but i am a noob and really need help

 

thx

Link to comment
Share on other sites

Hehe, I completely forgot about that! ... But, if you were to add an onclick handler to any old tag, then the website wouldn't downgrade nicely to non-JS enabled users.j

 

That's why it's always good to set up the site to work first without javascript being enabled. I often create submit buttons for non-javascript enabled systems, then hide them with javascript to prevent these issues. Or if I have an onlick for a div that shows something, then I just show them all at the start for the non-javascript enabled. It doesn't look as good as when javascript is enabled, but that's how things go for those who decide to block javascript (and I'm one of those people!).

Link to comment
Share on other sites

im not sure if this is what u mean but this is what i think u mean:

 

u put the div as a link, and when u click it, it changes the div to another?

 

is that what u mean?

 

You add a link or a div near the div. Then you add javscript so that when you click that link, the javascript navigates the dom, removes the div, and replaces it with a textarea, and fills that textarea with the text that was originally in the div.

 

would u be able to just show me the code on the html side.

 

Sure:

 

<div id="some_id">some text</div>

 

That's all there is for the HTML. It's javascript that does all the work.

 

when i click on the div and it changes, i want something else to change too. something i didnt click. ie: if ur in one tab and u click the other, the tab u r in changes the way it looks, and the one u clicked changes the way it looks.

 

This is all done with javascript as well.

 

im sorry if i sound like a noob but i am a noob and really need help

 

There's nothing wrong with being a noob! We were all there at one time. But what you are asking is way more than we can teach you in one thread. It requires some intermediate javascripting techniques that you have to learn. There are also some existing ajax scripts you can find for free on the internet if you look for them, or else you can use a javascript library (I recommend jquery) to make it a little simpler. But all of these are more than we can explain in this thread. I gave you the basic overview above, but it will take a lot of scripting to make this work. Google is your friend! Good luck.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.