Closed Thread Icon

Preserved Topic: javascript: two variables in value-tag (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18371" title="Pages that link to Preserved Topic: javascript: two variables in value-tag (Page 1 of 1)" rel="nofollow" >Preserved Topic: javascript: two variables in value-tag <span class="small">(Page 1 of 1)</span>\

 
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 12-10-2001 21:37

ok, i got a <SELECT> with a lot of <OPTION VALUE=... NAME=...> which are dynamically generated by php.

then i have a js-function which needs 2 values referring to the actually selected option of my <SELECT>
one of them is of course in the VALUE=... but where can i get the other one.

i wish there would be something like
<OPTION VALUE1=... VALUE2=... NAME=...>



InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-10-2001 21:43

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-10-2001 21:55

You could also do something like have the php output a javascript array of corresponding values that you can index



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 12-10-2001 22:07

ini, that's a nice idea, but it wont work since one of the values is an url. and it already contains : and i dont wanna program a text parser that filters all that out.
it's an url and the name of the url and the function outputs the complete <a ...> tag.

bitdamaged, that sounds interesting. but how do i then use it as values in the html code?



GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 12-10-2001 23:14

uhhhh i just found a very elegant solution myself:

look at this code:

code:
<INPUT type="button" value="Insert Linkcode" onClick="addText(document.editmenu.links.value,document.editmenu.links.options[document.editmenu.links.selectedIndex].text)">


cool, ey?

sorry for the horizontal scroll here, but i couldnt resist to use the code-tag.



DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 12-11-2001 10:59

Hi.
This is an interersting thing that I use from time to time that you might be able to use:

In any tag you can place an inline style, like this:
style="width:100px; height:100px;"
What you also can do is place your own attributes in the style tag, they are ignored until you pick them up...
Like this:
style="data:your url here; level:level one; zone:zone one;"
Place this in a form and call getData('yourmultidatafieldname') onSubmit.

Here's a testpage that works.

code:
<html>
<head>
<script language="JavaScript1.2">
function getObj(name){
if (document.getElementById)
return document.getElementById(name).style;
else if (document.all)
return document.all[name].style;
else if (document.layers)
return document.layers[name];
}

function getData(name){
x = getObj(name);
alert("data:" + x.data + ", level:" + x.level + ", zone:" + x.zone + ", form value: " + document.mulitidata.dataField.value);
return false;
}
</script>
</head>
<body>
This is a formfield that holds 3 set pieces of data + whatever you write in it.
On the same principle you can change all data on the attributes as you work your way through a form, or track clicks on a page, whatever...
<br>
<form name="mulitidata" onSubmit="getData('dataField');">
<input type="text" name="dataField" value="your text here" size="15" maxlength="15" style="data:your url here; level:level one; zone:zone one;">
<input type="submit">
</form><br>
and test it...
</body>
</html>




-{ a vibration is a movement that doesn't know which way to go }-

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 12-11-2001 12:22

now that is really interesting! i didnt know that. thanks!

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 12-11-2001 20:16

This is an interesting method, but keep in mind that it's a hack, and not the way style sheets are intended to be used. I mean, it should always work, but it's not really *morally* right to use it. =)

hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 12-12-2001 22:47

You could also write script to add "value2" properties to the options when the page loads. The DOM supports getAttribute also, which is the best method if you can stick to the right browsers.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 12-12-2001 23:00

the problem is, i cant.
it should work in NN4,6, opera, ie, mozilla.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 12-13-2001 20:43

I wish you'd say what you're trying to do, but try making two arrays, where the first element in each array corresponds to the first option in the list, and so on. then, when someone selects an option, read from the arrays.

« BackwardsOnwards »

Show Forum Drop Down Menu