Post in Forums
Create a Profile
Upload Pictures
Make Polls
Keep a Journal
Meet Friends
Have Fun
It's FREE!
Sign Up!
Avoid the cold & the crowds - Buy your Christmas gifts at Amazon.com
Forum Index > Computers & Internet > Web Design & Coding
>> Trying to edit a script, and I need help
Reply to Topic
Search Topic
Subscription
Author Message
New Post! Sep 29, 2009 @ 00:41:18#1
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

I have an input box, and I need the number that's put into the input box to be put into a line of javascript, so that when they click the javascript link, the value is submitted with it. It's like this:

<form>
<input type="text" id="Number"><<The number is input here
<a href="javascript: update_rating(1, >>I need that number to be here<< ) ">Click Here</a>
</form>

How can I do this?





"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
Edited: September 29, 2009 @ 00:41
New Post! Sep 29, 2009 @ 01:26:31#2
eL_TinO
booyaka!

Founder
Bogey Man
75157 points


Send PM


29/M/Las Cruces, New Mexico
Join Date: Oct 2004

err. try this.

document.getElementById('Number').options[document.getElementById('Number').selectedIndex].value




- Every time you toke up, God kills a Mexican
- Buy stuff at Amazon
On November 22, 2009
New Post! Sep 29, 2009 @ 01:35:11#3
eL_TinO
booyaka!

Founder
Bogey Man
75157 points


Send PM


29/M/Las Cruces, New Mexico
Join Date: Oct 2004

gah.. for some reason I thought you were using a <select ..> element.

Try this instead.

<form>
<input type="text" id="Number">
<a href="#" onClick="update_rating(1,document.getElementById('Number').value);return false; ">Click Here</a>
</form>




- Every time you toke up, God kills a Mexican
- Buy stuff at Amazon
On November 22, 2009
Edited: September 29, 2009 @ 01:37
New Post! Sep 29, 2009 @ 01:47:29#4
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

eL_TinO said:

gah.. for some reason I thought you were using a <select ..> element.

Try this instead.

<form>
<input type="text" id="Number">
<a href="#" onClick="update_rating(1,document.getElementById('Number').value);return false; ">Click Here</a>
</form>


AWESOME! It works! That is super cool! Thank you so much!




"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
New Post! Sep 29, 2009 @ 01:57:03#5
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

I was close before, I had

<form>
<input type="text" id="Number">
<a href="javascript: update_rating(1, document.getElementById('Number').value)">Click Here</a>
</form>

And nothing was happening. I don't even know javascript though really, so I don't know what I was expecting, lol.





"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
New Post! Sep 29, 2009 @ 02:07:28#6
eL_TinO
booyaka!

Founder
Bogey Man
75157 points


Send PM


29/M/Las Cruces, New Mexico
Join Date: Oct 2004

Lili said:

I was close before, I had

<form>
<input type="text" id="Number">
<a href="javascript: update_rating(1, document.getElementById('Number').value)">Click Here</a>
</form>

And nothing was happening. I don't even know javascript though really, so I don't know what I was expecting, lol.


for some reason the href="javascript doesn't like to work a lot of times, so I did onClick which works better, but you need the return false



- Every time you toke up, God kills a Mexican
- Buy stuff at Amazon
On November 22, 2009
New Post! Sep 29, 2009 @ 02:10:49#7
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

eL_TinO said:

for some reason the href="javascript doesn't like to work a lot of times, so I did onClick which works better, but you need the return false


what does return false do?




"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
New Post! Sep 29, 2009 @ 02:15:09#8
eL_TinO
booyaka!

Founder
Bogey Man
75157 points


Send PM


29/M/Las Cruces, New Mexico
Join Date: Oct 2004

Lili said:

what does return false do?



If you don't have it the browser tries to go to "#". That just tells the browser not to follow the href.



- Every time you toke up, God kills a Mexican
- Buy stuff at Amazon
On November 22, 2009
New Post! Sep 29, 2009 @ 02:16:10#9
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

Does it need to say 'javascript:' first, or can it just right into the code? I have it as onClick='javascript: ...' does it matter?





"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
New Post! Sep 29, 2009 @ 02:17:00#10
eL_TinO
booyaka!

Founder
Bogey Man
75157 points


Send PM


29/M/Las Cruces, New Mexico
Join Date: Oct 2004

Lili said:

Does it need to say 'javascript:' first, or can it just right into the code? I have it as onClick='javascript: ...' does it matter?



I would take it out, it doesn't need that.



- Every time you toke up, God kills a Mexican
- Buy stuff at Amazon
On November 22, 2009
New Post! Sep 29, 2009 @ 02:19:03#11
Lili
Silly Lili


Über-Monkey+
52741 points


Send PM


27/F/Sunshine Land, California
Join Date: Apr 2005

eL_TinO said:

I would take it out, it doesn't need that.


I got close to getting it to work by basically cutting and pasting snippets from other scripts that were doing something similar to what I was trying to do, but when you do that, you end up with other coders quirks in there, lol.

Good to know, I'll take it out.




"Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime."
1 minutes ago
Reply to Topic<< Previous Topic | Next Topic >>

Top

TFS Time: Sun 22 Nov 2009 08:42 am CST
Copyright © 2004-2009 Funky Llama Productions, LLC   |   Home   |   Contact   |   Privacy Policy   |   Terms of service

The Forum Site - Your premier source for everything LOGIN REGISTER