krash11554 Posted August 25, 2012 Share Posted August 25, 2012 I think i sound stupid asking this but i want a input box id to be a javascript variable and text that i write in. var id = 'interior'; <input type="text" id="addcar_ + id + hidden" /> Idk if you guys will understand this Link to comment https://forums.phpfreaks.com/topic/267549-simple-q/ Share on other sites More sharing options...
Mahngiel Posted August 25, 2012 Share Posted August 25, 2012 you'll need either getElementbyId or jquery's $('#element') Link to comment https://forums.phpfreaks.com/topic/267549-simple-q/#findComment-1372274 Share on other sites More sharing options...
krash11554 Posted August 25, 2012 Author Share Posted August 25, 2012 So something like this var id = 'interior'; $('#addcar').attr('id','addcar_' + id + 'hidden'); and the input box is this before i change the id. <input type="text" id="addcar" /> Link to comment https://forums.phpfreaks.com/topic/267549-simple-q/#findComment-1372275 Share on other sites More sharing options...
Jessica Posted August 25, 2012 Share Posted August 25, 2012 Why are you trying to do this? Link to comment https://forums.phpfreaks.com/topic/267549-simple-q/#findComment-1372357 Share on other sites More sharing options...
codefossa Posted August 27, 2012 Share Posted August 27, 2012 I think you want PHP, not Javascript. You're trying to set it based on a variable during the page load, which Javascript can't do. You could change it after the page loads, but that's completely pointless. You can just set it correctly the first time. <?php // Wherever you set it $id = "interior"; ?> <input type="text" id="<?php echo $id; ?>" /> Remember you can only use an id once, so don't use this for multiple elements. For that you'll want to use a class. Link to comment https://forums.phpfreaks.com/topic/267549-simple-q/#findComment-1372763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.